How to use setValue into a Table.

danielgarc__a
Giga Contributor

Hello everyone!
I have a problem trying to load into an attribute of a table.

I have one table, that has some attributes, and in the "New" form, I want to use a business rule to put a value into a field, so I tried a lot of ways to write the Script that do that, and fill something into that field but I don't know how to do it.

Someone knows how I can make to introduce a value into the field?

Thank you for your time!

7 REPLIES 7

Trust me you don't want to change the "Number" field and its incremental behavior.


However, I understood with the example provided by you.


You got number of fields on incident form.


You want to fill those automatically(with some planned values) while creating the incident.


This can be fairly achieved by writing glide script and set return value to respective field.


Nana5
Mega Guru

Hi Daniel,



You can glide the table, and based on your requirment, which field want to update u can, Please find the below example.Here m updating the workflow activity field.



//Update the workflow Activity




var gr = new GlideRecord('sysapproval_approver');


gr.addQuery('sysapproval',current.sys_id);


gr.query();


while (gr.next()) {


  var activity = gr.getValue('u_workflow_activity');


  if(activity== null){


  gr.setValue('u_workflow_activity','CAB Approval');


  gr.update();


  }



}



Regards,


Prakash Ranjan


Laurie Marlowe1
Kilo Sage

Hi Daniel,



You don't need to write code, unless you want to   Just go into the dictionary and change the settings as shown in the screenshot.   When you save the form, the incident number will be inserted.  



Capture.JPG



Please mark correct/helpful if this works for you.



Thanks,



Laurie