The CreatorCon Call for Content is officially open! Get started here.

logged in user should be set to caller field

Anusha M2
Kilo Contributor

logged in user should be set to caller field

5 REPLIES 5

Kalyani Jangam1
Mega Sage

Hi Anusha,

At the dictionary level of caller field set the default value as javascript: gs.getUserID()

Ankur Bawiskar
Tera Patron
Tera Patron

@Anusha M 

Hi,

there can be 3 ways in which this can be done

You can decide which approach to take

1) Dictionary default value

javascript: gs.getUserID();

OR

2) On load client script on that table

function onLoad(){
	
	if(g_form.isNewRecord()){
		g_form.setValue('caller_id', g_user.userID);
	}
	
}

OR

3) Display business rule on that table

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(current.isNewRecord())
		current.caller_id = gs.getUserID();

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks , this help me a lot , just want to ask which is best practice to do this