Populate a new field with Requested for value

Mallika Bhupath
Tera Contributor

Hi all,

I have a requirement to populate a field - "User for whom a new signature is being requested" with the same value that is on the "Requested For" field. 

Can someone please help me with the script. 

Also, I have to make the field "User for whom a new signature is being requested" read only and I have used a UI Policy. However, it doesn't seem to be working correctly.

Any ideas?

Thanks,

Mallika

1 ACCEPTED SOLUTION

Hello @Mallika Bhupath 

In addition to my previous answer:

  • This is because an onChange client script is in action. 
  • To auto-populate the requested_for field with logged in user an onload client script is required.
  • If requested_for field is already populating correctly then look for onload catalog Client script and add a code in it:
g_form.setValue("user_for_whom_a_new_signature_is_being_requested",'requested_for');

Note: Add this line after the requested_for field is set.

 

"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"

Thank You
Juhi Poddar

View solution in original post

7 REPLIES 7

Runjay Patel
Giga Sage

Hi @Mallika Bhupath ,

 

you can write Onchange client script on requested for field and use below script to set the same value.

 

g_form.setValue(‘new field name’, newValue);

to make read only field you can write ui policy.

 

Accept the solution if it helped

Juhi Poddar
Kilo Patron

Hello @Mallika Bhupath 

The issue is both the fields are of different type, one is reference and the other one is single line text. In this case we cannot directly set the value from "Requested for" field to "User for whom a new signature is being requested".

Steps:

  • Make both the field reference type, referencing to same table.
  • create an onchange client script:JuhiPoddar_0-1732072016451.png

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   //Type appropriate comment here, and begin script below
	g_form.setValue("user_for_whom_a_new_signature_is_being_requested",newValue);
}

 

  • Result: JuhiPoddar_1-1732072100238.png

    Note: newvalue in client script will return the sys_id

  • ReadOnly can be set in form itself JuhiPoddar_2-1732072283884.png

Hope this helps!

 

"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

Hi @Juhi Poddar ,

Thanks for the reply. 

The script is working okay however, the field is only populating when Requested for is changed and not with the logged in user. Any way I can modify this script?

Thanks,
Mallika

Hello @Mallika Bhupath 

Glad that you were able to achieve the requirements. However I have not added anything regarding logged in user as nothing was mentioned about it. If you need any help please drop your query here.

 

Thank you 

Juhi Poddar