Announcement

Collapse
No announcement yet.

Need to find the path for adding more phone types while Exporting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to find the path for adding more phone types while Exporting

    Here, https://forum.espocrm.com/forum/feat...-phone-numbers yuri have mentioned a script that allows me to add more phone types while exporting, but I'm unable to find the path. Can anyone help me?

  • #2
    You may find it useful:
    - First implement a solution with the ability to transfer data from phoneNumberData to a text field https://forum.espocrm.com/forum/gene...660#post111660.
    - Then you can export data from this text field in the form of absolutely all phone numbers that have a contact, lead or account.​

    Click image for larger version  Name:	image.png Views:	0 Size:	17.3 KB ID:	111809
    Last edited by victor; 10-29-2024, 11:11 AM.

    Comment


    • #3
      victor , this is fine. I'm getting a 'Syntax error: Attribute name contains not allowed characters,' but I can fix it. Is it not possible to implement this in the way yuri mentioned? I don’t want this field in the list view since it’s not useful for click-to-call functionality as it’s not a tel link; exporting is my main concern.

      Comment


      • #4
        I worked on the formula and fixed the syntax errors. However, I am facing one issue: emails are appearing as links, but phone numbers are not. Please review the attached screenshot. Is there any way I can achieve this?"


        $phoneNumbersCount = array\length(phoneNumberData);

        $phoneNumberData = json\encode(phoneNumberData);

        $phoneNumbersArray = ''; // Initialize as an empty string

        $i = 0;

        while ($i < $phoneNumbersCount) {

        $phoneNumber = json\retrieve($phoneNumberData, string\concatenate($i, '.phoneNumber'));

        // $phoneNumberTel = string\concatenate($phoneNumber);

        $phoneNumbersArray = string\concatenate($phoneNumbersArray, $phoneNumber, '\n');

        $i = $i + 1;
        }

        cMyPhoneNumber = $phoneNumbersArray;


        $emailAddressesCount = array\length(emailAddressData);

        $emailAddressData = json\encode(emailAddressData);

        $emailAddressesArray = ''; // Initialize as an empty string

        $i = 0;

        while ($i < $emailAddressesCount) {

        $emailAddress = json\retrieve($emailAddressData, string\concatenate($i, '.emailAddress'));

        $emailAddressesArray = string\concatenate($emailAddressesArray, $emailAddress, '\n');

        $i = $i + 1;
        }

        cMyEmailAddress = $emailAddressesArray;
        Last edited by Ashif Malayil; 10-29-2024, 05:26 AM.

        Comment


        • lazovic
          lazovic commented
          Editing a comment
          To make phone numbers appear as links and be able to be called, you need this line from the above post: $phoneNumberTel = string\concatenate('[', $phoneNumber, ']', '(tel:', $phoneNumber, ')');

          We would also be grateful if you could point out what specific syntax errors you found in the provided formula script solution.

      • #5
        Still after exporting this, both columns are empty in the sheet.
        Last edited by Ashif Malayil; 10-29-2024, 06:43 AM.

        Comment


        • #6
          Hi Ashif Malayil,

          I checked how the fields are displayed in different exported file types. Please review:

          CSV export file:

          Click image for larger version

Name:	image.png
Views:	42
Size:	11.1 KB
ID:	111825

          XLSX export file:

          Click image for larger version

Name:	image.png
Views:	38
Size:	14.0 KB
ID:	111826​​

          Comment


          • #7
            Thank you, lazovic . It's working now while exporting to CSV.

            - I was getting the error "Syntax error. Attribute name contains not allowed characters" while using the formula shared by Yuri.
            - After adding the formula $phoneNumberTel = string\concatenate('[', $phoneNumber, ']', '(tel:', $phoneNumber, ')'); the phone number field is still in text format. Please find the attached screenshot for reference
            Last edited by Ashif Malayil; 10-29-2024, 07:42 AM.

            Comment


            • #8
              Ashif Malayil,

              Sometimes it happens that if you copy text from a forum, an extra character is added (in the formula script window in the EspoCRM instance, it looks like a red dot at the end). That's why you got the error initially.

              Please use this formula script; I changed it to match the names of your custom fields:​
              Code:
              $phoneNumbersCount = array\length(phoneNumberData);
              
              $phoneNumberData = json\encode(phoneNumberData);
              
              $i = 0;
              
              while ($i < $phoneNumbersCount) {
                  
                  $phoneNumber = json\retrieve($phoneNumberData, string\concatenate($i, '.phoneNumber'));
                  
                  $phoneNumberTel = string\concatenate('[', $phoneNumber, ']', '(tel:', $phoneNumber, ')');
                  
                  $phoneNumbersArray = array\push($phoneNumbersArray, $phoneNumberTel);
                  
                  $i = $i + 1;
              }
              
              cMyPhoneNumber = array\join($phoneNumbersArray, '\n');
              
              $emailAddressesCount = array\length(emailAddressData);
              
              $emailAddressData = json\encode(emailAddressData);
              
              $i = 0;
              
              while ($i < $emailAddressesCount) {
                  
                  $emailAddress = json\retrieve($emailAddressData, string\concatenate($i, '.emailAddress'));
                  
                  $emailAddressesArray = array\push($emailAddressesArray, $emailAddress);
                  
                  $i = $i + 1;
              }
              
              cMyEmailAddress = array\join($emailAddressesArray, '\n');

              Comment


              • #9
                lazovic It’s working perfectly. In List view and while Exporting.
                Last edited by Ashif Malayil; 10-29-2024, 09:53 AM.

                Comment


                • #10
                  lazovic , are you aware of the process that yuri mentioned in this post: Importing Multiple Email Addresses and Phone Numbers? If it works, it would be an excellent feature to implement.
                  ​​
                  Last edited by Ashif Malayil; 10-30-2024, 09:20 AM.

                  Comment

                  Working...
                  X