function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Javier CGJavier CG 

Convert text to id in formula editor

I am creating a quick action to create record (Event) and I need to assign default values on some fields.
One of the fields is the Assign to. Usually the event is assigned to the current user, but in some cases I need to assign the event to one concrete user.
I try to do it through this formula:

IF( $Profile.Name != "Profile 1" && $Profile.Name != "Profile 2", "XXXXXXXXXXXXXXX",  $User.Id )

Where "XXXXXXXXXXXXXXX" is the id of the concrete user. But this formula raise error:

 Error: Formula result is data type (Text), incompatible with the expected data type (Search(Calendar,User)).

There is any form to cast the text string of the id into id or some other form to achieve that I need to do?
Best Answer chosen by Javier CG
Javier CGJavier CG
Finally, I did it through a Lightning Component.

All Answers

Raj VakatiRaj Vakati
try this 
 
IF( $Profile.Name != "Profile 1" && $Profile.Name != "Profile 2", Text(Id),  Text($User.Id) )

 
Javier CGJavier CG
Thank you Raj, but Text(Id) raise an error because you can´t use the Text function with a text parameter (Text('XXXXXXXXXXXXXXX')).
And I don´t need to cast the $User.Id, that´s an Id and runs well.
The problem is in the if part of the IF function, when I return 'XXXXXXXXXXXXXXX' as a text and like the 'Assigned to' field has Id data type, I get the error. I need to cast or convert the text id to Id to return it in the if section of the IF function, but I can´t find a function or other way to do it.
mayur K 12mayur K 12
Thanks This Solution, I Also try it.
Regard:  vbtcafe (http://www.vbtcafe.com/)
Javier CGJavier CG
Finally, I did it through a Lightning Component.
This was selected as the best answer