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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashif Malayil
    Senior Member
    • Dec 2023
    • 171

    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?
  • victor
    Active Community Member
    • Aug 2022
    • 727

    #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

    • Ashif Malayil
      Senior Member
      • Dec 2023
      • 171

      #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

      • Ashif Malayil
        Senior Member
        • Dec 2023
        • 171

        #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.
      • Ashif Malayil
        Senior Member
        • Dec 2023
        • 171

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

        Comment

        • lazovic
          Super Moderator
          • Jan 2022
          • 809

          #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:	60
Size:	11.1 KB
ID:	111825

          XLSX export file:

          Click image for larger version

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

          Comment

          • Ashif Malayil
            Senior Member
            • Dec 2023
            • 171

            #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

            • lazovic
              Super Moderator
              • Jan 2022
              • 809

              #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

              • Ashif Malayil
                Senior Member
                • Dec 2023
                • 171

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

                Comment

                • Ashif Malayil
                  Senior Member
                  • Dec 2023
                  • 171

                  #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...