how can i update current object in UI page?

IamAmolB
Tera Guru

Hi Experts,

I have created a UI page where i am offering 3 operations like

1. save (like save & continue)

2. Exit (move to home page)

3. cancel (as OOB featured)

to make a save button enable i need current object to do the update (like current.update)

do we have any solution for this as i am not able to use current object in processing script any alternative?

how can i update the record on save button click of UI page.

Regards,

Amol Bavaskar

9405444404

1 ACCEPTED SOLUTION

IamAmolB
Tera Guru

Hi All,



I was wanted to update the form on button click on UI page (which is custom button ) for that we can have a method g_form.submit(); It should be written on client side and it will fulfill my updating requirement.



Thank you all for participating and replying me so quickly to answer.




Regards,


Amol Bavaskar


View solution in original post

9 REPLIES 9

Brad Tilton
ServiceNow Employee
ServiceNow Employee

There is no default current object associated with a ui page, so typically people pass in the sysid as a url parameter and then use gliderecord to look it up and update it in the processing script or client script (via ajax).


Hi Brad,



I appreciate your response thank you so much for that but,



GlideRecord is not working for me.



is there any other way to do this?




Regards,


Amol


As b-rad mentioned, there is no "current" Object on a UI Page, unless you define one. How are you accessing the record you wish to update? GlideRecord Class should be able to do this, so perhaps you have a script error in the way you're calling GlideRecord. Here is an example (note that the GlideRecord Class is called inside the evaluate tags and can be used in other evaluate sections once defined/retrieved).



<g2:evaluate jelly="true">


      // Get sys_id from URL parameter


      var incSysid = RP.getParameterValue("sysparm_sys_id");


      // Get GlideRecord


      var current = new GlideRecord('incident');


      if(current.get(incSysid)){


              // do something with the record here


      }


</g2:evaluate>


<p>Incident State Before Update: $[current.state.getDisplayValue()]</p>


<g2:evaluate jelly="true">


      // Update State to Closed


      current.state = 7;


      //current.update();


</g2:evaluate>


<p>Incident State After Update: $[current.state.getDisplayValue()]</p>



jake.gillespie : your answer was helful