Hi all,
I just need some pointers on getting started with this. I've got a custom lookup field on an entity that points to a lead. I want to when an email is created and regarding is that entity to default the to field to the lead lookup on that entity.
I've been searching around for a sample code snippet and looking through the CRM REST builder but just can't seem to figure it out. Just a simple code snippet will do to point me in the right direction.
I know you've got to create an activitypointer record I think...
Kind regards,
Mike
Hi Mike,
The last error 'getValue of null' is due to incorrect schema name of regarding field. It is regardingobjectid not '_regardingobjectid_value'.
However this is not you need to do. You need to retrieve the lead lookup value from the case entity using web api (refer the previously shared blog). Once you get the details of the leade (i.e. name, id), you set the to field as follows-
-----------------
var partlist = new Array();
partlist[0] = new Object();
partlist[0].id = "ff4070a3-d5eb-e911-a812-000d3a7957a4";
partlist[0].name = "Susane";
partlist[0].entityType = "lead";
formContext.getAttribute("to").setValue(partlist);
---------------------
Hope this helps.,
Hi Ravi,
I'm fine with retrieving the lead ID. It's just I'm not sure how to set it onto the email's "To" field upon form load of the email. So basically as per the below screenshot. When I add a email from the timeline. I don't want it to default to the Customer field of the case but instead default the "To" field to the lead lookup field instead.
So this is what happens when I select email from the timeline:
I then tried retrieving the regardingobjectid upon form load of the email, which I'm getting weird results.
It seems like the getValue result is null which is strange.
function setEmail (executionContext) { var formContext = executionContext.getFormContext(); var regarding = formContext.getAttribute("_regardingobjectid_value").getValue(); console.log(regarding); }
Hi Mike,
You need to use Web API to retrieve the lead lookup field from your custom entity when you set it as regarding...i.e. on change of regarding.
You can refer the below log which has the same implementation-
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156