Hi
I have a field (contactinfo) in a dataset that has a large amount of data in it and I am hoping to Split it via an arcade expression in a pop up. I thought the best way to split them in the expression would be by the comma.
The data in the field is shown below:
Owner ID: 0, CLIENT_TYPE_CODE: C, NAME1: JAMES HAMMERS INC , NAME2: , STREET1: 5783 TURNSTONE DR, STREET2: , CITY: LANGSVILLE, PROV_STATE_CODE: BC, COUNTRY_CODE: CAN, POSTAL_ZIP: V0N3A7, PHONE1: , PHONE2: , FAX: , CLIENT_NET_ADDR: , CONTACT_NAME: , CONTACT_PHONE1: , CONTACT_PHONE2: , CONTACT_FAX: , CONTACT_NET_ADDR:
I've tried something like this Split($feature.contact_info) if ,= true, however I think I'm getting a syntax error.
I'm fairly new to arcade, feel like this is probably quite simple and I'm just missing it.
Thanks for any help!
Solved! Go to Solution.
The use can use that in an expression like this to show only the values that aren't blank
var data = 'Owner ID: 0, CLIENT_TYPE_CODE: C, NAME1: JAMES HAMMERS INC , NAME2: , STREET1: 5783 TURNSTONE DR, STREET2: , CITY: LANGSVILLE, PROV_STATE_CODE: BC, COUNTRY_CODE: CAN, POSTAL_ZIP: V0N3A7, PHONE1: , PHONE2: , FAX: , CLIENT_NET_ADDR: , CONTACT_NAME: , CONTACT_PHONE1: , CONTACT_PHONE2: , CONTACT_FAX: , CONTACT_NET_ADDR:';
var theArray = Split(data,',');
var output = '';
for (var index in theArray) {
var theInfo = Split(theArray[index],':');
if (!IsEmpty(Trim(theInfo[1]))) output += `${Trim(theInfo[0])}: ${theInfo[1]}${TextFormatting.NewLine}`;
}
return output;
The syntax for the Split function is Split(inputText, separatorText, limit?, removeEmpty?). Your code should be
var theArray = Split($feature.contact_info, ',');
The use can use that in an expression like this to show only the values that aren't blank
var data = 'Owner ID: 0, CLIENT_TYPE_CODE: C, NAME1: JAMES HAMMERS INC , NAME2: , STREET1: 5783 TURNSTONE DR, STREET2: , CITY: LANGSVILLE, PROV_STATE_CODE: BC, COUNTRY_CODE: CAN, POSTAL_ZIP: V0N3A7, PHONE1: , PHONE2: , FAX: , CLIENT_NET_ADDR: , CONTACT_NAME: , CONTACT_PHONE1: , CONTACT_PHONE2: , CONTACT_FAX: , CONTACT_NET_ADDR:';
var theArray = Split(data,',');
var output = '';
for (var index in theArray) {
var theInfo = Split(theArray[index],':');
if (!IsEmpty(Trim(theInfo[1]))) output += `${Trim(theInfo[0])}: ${theInfo[1]}${TextFormatting.NewLine}`;
}
return output;
Hi Ken, appreciate the quick response. I tried the code and just received an empty box. Do I need to put a sort by for each identifier so that it knows for example OWNER ID: 0 is split into a sperate faux field?
Or do I need a separate expression for each line I'd like to see, as seen below?
You can remove the Field element, then add in a Text element. Inside the Text element editor, click the Field dropdown and add your Expression. The Configure Popups should look something like this
Really appreciate your help, yes this works perfectly. Thank you!