UI Action to Create a Record in another table

Invoke
Kilo Contributor

Hello,

I am wanting to create a new Release record off the back of an Incident. I have therefore written the UI Action below however it appears to take me back to a list of all Incidents therefore my UI Action is not working correctly, its not even creating my release.

NOt sure what I need to set for my GlideRecord in the first line. I have used "release_project" and "release" without any joy.

Further to this I have created a new view which is test_release - not sure where I need to fit this into my UI Action?

Here is the UI Action I have written:

var prob = new GlideRecord("release_project");
release.short_description = current.short_description;
release.cmdb_ci = current.cmdb_ci;
release.priority = current.priority;
var sysID = release.insert();

current.release_id = sysID;
var mySysID = current.update();

gs.addInfoMessage("Release" + release.number + " created");
action.setRedirectURL(release_project);
action.setReturnURL(current);

14 REPLIES 14

If you need to apply only one view then the easiest way would be to use the View Rules section under System UI. You can see a bit more about it in the Wiki http://wiki.service-now.com/index.php?title=View_Management

If you are trying to apply this always with out exception do not put any conditions on it.


Thanks very much for all your help!!! You have helped alot!!

Thanks


Invoke
Kilo Contributor

Oops. One other thing not working with this.

I am wanting to pass the values which reside in the cmdb_ci field (Configuration Item) in Incident (extension of the task table) to the Product field within the release_project table (not an extension of the task table).

Any ideas???

Thanks


Since release_project is not an extension of the task table you will have to make sure you have a field that is setup to be reference of the cmdb_ci table. if you have already done that we will just need to make sure you have the right information in your script to match the name of your field. If the field is one that you added it would have u_field_name.

ex.
release.u_cmdb_ci = current.cmdb_ci;

You can also check the fields name by right clicking on it and you will see the name at the bottom.



Not applicable

Hi. I am trying to do something similar.
I want to generate an Outage record (cmdb_ci_outage) from an Incident record. via a UI action.
I have tried copying and amending the existing scripts for generating a problem or change via this method, to no avail.

Help!