Smartlook Up for Contact Table

ATTENTION: This forum is no longer active. Please navigate to our new support site at https://support.starfishetl.com/
Viewing 4 posts (of 4 total)
srijanapokharel
User - Author
Post count: 27
#1

Hi,
I am trying to write a VBScript which checks whether the field "Address1_City" in "Contact" Table is already populated in previous job or not. If the field is not already populated I would like to populate the new value in the current job/stage and skip if it already has some value. I am trying to get the value from the destination field using - SmartLookUp("Contact", "Address1_City", ""). Please let me know the best practice with example to do this?

Thanks

Comments (4)

Aron Hoekstra's picture Aron Hoekstra
Administrator
Post count: 2
#2

Well you'll need to provide some kind of filter on your SmartLookup to select which contact you're looking for. Something like:

SmartLookUp("contact", "Address1_City", "contactid=@@ORG:ContactID@@")

Log in to post comments
Aron Hoekstra's picture Aron Hoekstra
Administrator
Post count: 2
#3

also note for Microsoft CRM your table names are case-sensitive through the smartlookup and usually they are always lower case.. so you should lookup by "contact", not "Contact".. let me know if that helps.

Log in to post comments
srijanapokharel's picture srijanapokharel
User - Author
Post count: 27
#4

My scenario looks like this - I have trying to update the "contact" table with the address1_line1 and AddressID. First, I am insterting address1_line1 in the contact table with some filter condition. Second, I want to check if I already have some/same address1_line1 in the "contact" table. If I don't have same/some address in address1_line1, I would like to put this new address to address2_line1. What would be the best practice to handle this scenerio.

Thanks

Log in to post comments
Aron Hoekstra's picture Aron Hoekstra
Administrator
Post count: 2
#5

Here's how I think I would handle this.. I would perform the lookup first and set up a series of variables in advance to map your fields to.

Make sure you turn on Skip Blank Writes in your stage. I'd set up a series of Global variables.. (in Global VBScript)

Dim Addr1_Line1, Addr2_Line1
Then set up a per-row VBScript Procedure that did something like this:

Sub VBScriptProcedure
Dim Current_Address
'The line below will fetch the current address for this row
Current_Address = SmartLookup("contact", "address1_line1", "contactid=@@ORG:ContactID@@")

'Now see if the address is currently blank or if it doesn't match my new address
If Current_Address = "" or Current_Address <> "@@ORG:Address1@@" Then
Addr1_Line1 = "@@ORG:Address1@@"
Addr2_Line1 = ""
Else
Addr1_Line1 = ""
Addr2_Line1 = "@@ORG:Address@@"
End If
End Sub
Now for your CRM address1_line1 field, map it as a VBScript Function Field and simply return the Addr1_Line1 variable out, and the same for address2_line1. Like this:

Function ScriptedField
ScriptedField=Addr1_Line1
End Function
Let me know if you have any questions...

Log in to post comments
Viewing 4 posts (of 4 total)

Forum Login

Login or sign up for our forums to connect to the user community.

Reply

You must log in to post.

Not a Member? Register.