Convert User's ID to User's Name in Email Script | Community
Skip to main content
Valerie_Armstro
Level 9
July 11, 2016
Question

Convert User's ID to User's Name in Email Script

  • July 11, 2016
  • 2 replies
  • 6258 views

Hello Community,

There is a lookup field (to the Users object) on a Salesforce Custom Object that I need to utilize in an upcoming campaign.  In the email, I would want to User's Full Name to appear.

Assuming I need an email script to do this, I've tried various ways to get the Name (not the ID) to pop in, but have been unsuccessful.

Here is the working script that returns the User ID:

#set( $psm_name = "Onboarding Specialist" )

#if( ${PSM__cList.get(0).PSM_Owner__c} )

#set( $psm_name = ${PSM__cList.get(0).PSM_Owner__c} )

#end

$psm_name

Is there a simpler way than having a bunch of if/then statements that would need to be maintained as the Onboarding team changes?

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Scott_McKeighe2
Level 4
July 15, 2016

Are you trying to evaluate whether a custom object field value matches another field?

Also, have you tried setting the PSM Owner value as a variable before evaluating it with an #if? Something like:

#set ( $a = ${PSM__cList.get(0).PSM_Owner__c} )

#if ( !$a )

Display a default value if A is null

#else

$a

#end

We just had a huge overhaul of some of our assets that utilized Velocity and custom SFDC objects, and that was (essentially) the method we had to follow.

Valerie_Armstro
Level 9
July 18, 2016

Hi Scott,

I am attempting to retrieve the full name of the user who is assigned to the onboarding record. Onboarding is a custom object we have in SFDC. On the Onboarding object, there is a lookup field (related to the User object) called Onboarding Specialist.

When I use the email script I put in my initial question, it returns the SFDC User ID instead of the name of the User.

Example:

Ideally, I would like the script to lookup the User ID and return that user's full name (e.g. Valerie Armstrong instead of 005C0000006nTBAIA2) without having a bunch of if/then statements that would need to be managed as new onboarders come onto the team.  Would the method you provided work in such a case?

Thanks!

Casey_Grimes2
Level 10
July 18, 2016

Hi Valerie,

Theoretically yes, you could just do a large number of if/then statements, but if you plan on using this on any sort of regular basis I'd just make a quick Marketo custom object holding the SFDC User IDs and their corresponding values and reference that.

July 20, 2016

I think it is doable with 'webhooks'. You can write a web hook service that will fetch the user name from SFDC from the user id. And return that when the webhook is called from Marketo.

Also webhooks might be better solution than email scripting. Because using email scripting, all you can do it 'show' the user name in that email. Thus in every such email, you will have to code email script. While using webhook, you can populate a field in Marketo with the user name and use it in anyplace you want.

Hope this helps

Rajesh Talele