How do you set the opening current user on a record producer default value

wakespirit
Kilo Guru

Dear all,

I have an UI action which open a Record producer which will be in charge of creating a task assigned to the user which has open the record producer.

In my User table record I add a UI action button.
In my record producer it is mapping to table task

When my Record Producer loads, I need to set the task.assignTo value of my producer to be the user which has open the UI action

For exemple, if my current user record name is : John
Then user press on UI action which shows the record producer
Record producer field assignto should be = to john

How can I achive this ?

I guess I should do it from a catalog client script onLoad ?
What script should I write in to achive my goal ?

Thanks for help

regards

1 ACCEPTED SOLUTION

Hi Wakespirit,

I assume this issue is resolved as per the other thread.

Kindly mark the answer as correct so that others get benefitted from it.

View solution in original post

7 REPLIES 7

User177031
Kilo Guru

Hi wakespirit,

I think you can below script as default value. Logged in User will be the one who can click the UI Action.

javascript:gs.getUserID();

 

On Load client script might impact when the Record Producer is opened through portal directly.

- Thank you.

Thnaks for your reply.

I miss you miss understand.

I do not want to get the current login user, but instead the user record sys_id value which was open and call the record producer.

The process is has below :

- I go to users in Servicenow
- open a user record 
- Click on New task button ( Ui Action)

Record producer default value Assigned to = user.sys_id

 

find_real_file.png

 

How to achive that field initialisation of my record producer ?

Thnaks for help

regards

Hi Wakesprit,

In the UI action, you can get the user id of the record from which the UI action is clicked by using

g_form.getUniqueValue()

Then you can pass this as a parameter to your Record producer and can set it.

Kindly mark my answer as correct if this works.

Here is below my UI action :

var gform=new GlideDialogWindow('test_producer');
	var user=g_form.getUniqueValue();
	
	gform.setPreference('name_text',user);
	gform.setTitle('Test record producer');

	gform.render();

I added what you suggest .
Then I pass the variable to the dialog window as name_text variable

How can I set my Recorder producer field with it then ? 

screen shot would help

thnaks