Parse text and look up ID based on result

Parse text and look up ID based on result

This script parses out the first Lead Source from a comma or semi-colon separated list and then gets the Lead Source ID from an xRef list.

Function ScriptedField
	Dim ls
	Dim res
	ls = "@@ORG:CUSTOM07@@"
	If Len(ls) <> 2 Then
		If InStr(ls,",") > 0 Then
			ls = Left(ls,InStr(ls,",")-1)
		End If
		If InStr(ls,";") > 0 Then
			ls = Left(ls,InStr(ls,";")-1)
		End If
		res = ls
	Else
		res = XrefRead("sf-LeadSource",ls)
	End If
	ScriptedField=res
End Function
    • Related Articles

    • Look in many xref lists for an origin ID

      Function ScriptedField Dim newid Dim oldid oldid = "@@ORG:OLDID@@" newid = XrefRead("Accounts",oldid) If Len(newid) = 0 Then newid = XrefRead("Contacts",oldid) End If If Len(newid) = 0 Then newid = XrefRead("Opportunities",oldid) End If If Len(newid) ...
    • Validate and parse JSON

      This is a link to a page that will validate/parse your JSON: http://jsonlint.com/
    • Exp Detect URLs in text with JavaScript

      A tool that can detect URLs in text with JavaScript can be found here: https://www.regextester.com/96249%7CRegular
    • Parse XML

      First I add code and External Assemblies to the .NET GLobal section of the Mapping tab: using System; using System.Collections.Generic; using System.Xml; XmlDocument demographicsXML = new XmlDocument(); XmlNodeList nodes; External Assemblies: ...
    • SugarCRM REST Connector

      SugarCRM REST Origin Use JSONLint to validate JSON: https://jsonlint.com/. Sample Origin Filters See the GET /<module> filterList in the SugarCRM REST Help: https://SERVER/rest/v10/help/ Note the [{...}] surrounding the filter. This is required. ...