Hey all,
I have a parent field on lead called (salesChannel) the parent field has Account - User, I tried to update this parent field when a lead is created (if lead is created by portal user I set up the salesChannelType = "Account" - salesChannelId = createdBy.accountId - salesChannelName = createdBy.accountName but it doesn't work (I want to update the sales channel to type account and link to account of the portal user). I have an account linked to the portal user but it won't work.
NB: when a lead is created by a normal user the salesChannel field is updated as (salesChannelType = "User" - salesChannelId = createdById - salesChannelName = createdByName ) and it works just fine, only when I a lead is created by portal user then it won't update the salesChannel parent field. I am sure that the portal user has account set.
Can anyone help please.
Thanks
Update: Solution
I have solved the problem using formula existing function, below is my code to update parent field (salesChannel) with portal user's account :
I hope this will help anyone in need.
Thanks
Rabii
I have a parent field on lead called (salesChannel) the parent field has Account - User, I tried to update this parent field when a lead is created (if lead is created by portal user I set up the salesChannelType = "Account" - salesChannelId = createdBy.accountId - salesChannelName = createdBy.accountName but it doesn't work (I want to update the sales channel to type account and link to account of the portal user). I have an account linked to the portal user but it won't work.
NB: when a lead is created by a normal user the salesChannel field is updated as (salesChannelType = "User" - salesChannelId = createdById - salesChannelName = createdByName ) and it works just fine, only when I a lead is created by portal user then it won't update the salesChannel parent field. I am sure that the portal user has account set.
Can anyone help please.
Thanks
Update: Solution
I have solved the problem using formula existing function, below is my code to update parent field (salesChannel) with portal user's account :
HTML Code:
$type = "Account"; // get account id of portal user (current createdBy) using createdBy.contactId on record\findRelatedOne $accountId = record\findRelatedOne('Contact', createdBy.contactId, 'accounts', 'createdAt', 'desc'); // grab the name attribute of the found account of the portal user using record\attribute $name = record\attribute('Account', $accountId, 'name'); ifThen($accountId, entity\setAttribute('salesChannelType', $type); entity\setAttribute('salesChannelName', $name); entity\setAttribute('salesChannelId', $accountId); );
Thanks
Rabii
Comment