How can I set the a Change Owner field to default to be the created by user when a Change is Created?

frappe
Kilo Expert

On our change request form we have a new field called Change Owner.     The field is required.     I want the Change Owner field to be set to the Created by user by default. Is there a way to do that?

1 ACCEPTED SOLUTION

Kristin,



    You can use either "javascript:gs.getUserID()" in the default value or dynamic default. You can manage your code better by using dynamic defaults



Thanks,


Abhinay




Please mark Helpful, Like, or Correct depending on the impact of the response


View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

Yes there is. Use a BEFORE business rule with insert checked. Something like this (Untested and adjust u_owner to the name of your owner field name as needed.)



Check "Advanced"


Script:


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



  current.u_owner = gs.getUserID();



})(current, previous);


Abhinay Erra
Giga Sage

Kristin,



  Configure the dictionary of that field and use dynamic default to "Me" as shown in the snapshot


find_real_file.png



Thanks,


Abhinay




Please mark Helpful, Like, or Correct depending on the impact of the response


Deepa Srivastav
Kilo Sage

you can use gs.getUserID() in dynamic default value..or existing option me , check OOB Opened by field dictionary in incident form..




Getting a User Object - ServiceNow Wiki



Please mark Helpful, Like, or Correct depending on the impact of the response


Jim Coyne
Kilo Patron

Set the "Default" value on the Dictionary Entry record for that custom field to be "javascript:gs.getUserID()".   That will default the field to the user who creates the new record.



You do that by right-clicking on the field label and select "Configure Dictionary".