UI Action to Create a Record in another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2009 07:17 AM
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);
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2009 07:40 AM
Try changing your first variable from prob to release.
var release = 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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2009 09:19 AM
Stupid me - yip corrected that and the Release is created however I am returned to a list of all Incidents once I have clicked the "Create Release" UI Action?
Also - this release should be created using my test_release view.
Any thoughts on the above?
Thanks very much for your first response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2009 11:26 AM
As far as being directed to a list of records rather than your new release try the code below. When setting the return link you want your new release rather than the table.
action.setRedirectURL(release);
Views are not applied to the record you are creating through this UI Action, you would need to change the view with another business rule. Let me know if that is not what you were talking about.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2009 12:34 PM
The redirect works a treat - brilliant, thanks!
I haven't really applied views via a business rule therefore any information would be appreciated......
Thanks again!