Formatting Billing address from a text field in Salesforce

  • raghu.a_85
    Participant
    7 years, 11 months ago #5411

    I have a field in salesforce which holds the Billing address in Text type field. Basically I need this be formatted whne I send it to quickbooks .
    For example :
    Needs to be as below
    #65, Soundarya parramount
    54,Malleshwaram
    Banglore
    India

    Not like Below,

    #65, Soundarya parramount54,Malleshwaram
    Banglore
    India

    Need to seperate based on next line character

    susmith.v_91
    Participant
    7 years, 11 months ago #5638

    Quickbooks Maintains the address fields different from Salesforce.

    In order to Split the address from Salesforce Text area field based on the new line character, we have to make use of Java script.

    In DBSync, you can either write the Java script in the mappings or make use of Functions where you can develop or write user defined functions.

    I am providing an example of a Java script that can be written in the maps.

    In Order to get the first line, You can implement the below script

    {return VALUE(““).split(“n”)[0];}

    This will split the text area data and return only the first line.

    For the second line, use the below script

    {String ST = VALUE(““);int L1E = ST.indexOf(“n”);int L2E = ((L1E>-1)?(ST.indexOf(“n”,L1E+1)):(-1));int SL = ST.length(); if (SL>L1E & L2E>L1E) { String L2x = ST.substring(L1E+1,L2E); String L2 = L2x.substring(0,((L2x.length()>41)?(41):(L2x.length()))); return L2; }else if (SL>L1E & L1E>-1) { String L2x = ST.substring(L1E+1,SL); String L2 = L2x.substring(0,((L2x.length()>41)?(41):(L2x.length()))); return L2; }else { String L2 = “”; return L2; }}

    And for the third line, use the below script

    {String ST = VALUE(““);int L1E = ST.indexOf(“n”);int L2E = ((L1E>-1)?(ST.indexOf(“n”,L1E+1)):(-1));int L3E = ((L2E>-1)?(ST.indexOf(“n”,L2E+1)):(-1));int SL = ST.length(); if (SL>L2E & L3E>L2E) { String L3x = ST.substring(L2E+1,L3E); String L3 = L3x.substring(0,((L3x.length()>41)?(41):(L3x.length()))); return L3; }else if (SL>L2E & L2E>-1) { String L3x = ST.substring(L2E+1,SL); String L3 = L3x.substring(0,((L3x.length()>41)?(41):(L3x.length()))); return L3; }else { String L3 = “”; return L3; }}

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.