How to make use of System property in UI Action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 10:04 PM
I want to create a copy request through the system property fields.(additional_comments,state).Whenever i create a request i am getting additional comments value as blank.Please guide me in this.
function showConfirmationPopup() {
var answer = confirm("Are you sure you want to make a copy of this request?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'copy_req'); //MUST call the 'Action name' set in this UI Action
} else {
return false;
}
}
if (typeof window == 'undefined')
openCopy();
function openCopy() {
var curSysID = current.sys_id;
var curNum = current.number;
var cpy = new GlideRecord("sc_req_item");
var value = gs.getProperty("com.snc.request.copy.rl.task_ci.attributes");
cpy.additional_comment=value.additional_comment;
cpy.parent = curSysID;// var abc = [];
var sysID = cpy.insert();
cpy.work_notes = "This incident was created from a copy of incident " + curNum + " by user " + gs.getUserDisplayName() + " See the list of incidents created by the same caller below for more information.";
cpy.update();
current.work_notes = "This incident was used to as a copy to create " + cpy.number + ". See the list of incidents created by the same caller below for more information.";
var mySysID = current.update();
action.setRedirectURL(cpy);
action.setReturnURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 01:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 02:36 AM
Hi,
You can pass only additional comment that should not be of any issue.
Intent of having Property defined is you are trying to store multiple field values in One Property , which will give you an advantage that if you need to use the same field mapping anywhere else in the script you can directly call the property instead of defining every time or hard coding it in different script.
Using Property is a good Practice when you need to re use these kind of mappings and I would suggest define it as a JSON format as it looks more cleaner and easy to use with good performance.
If you need to define just one attribute, you can define it like below:
{"additionalComment": "This is copied"
}
One thing to note while defining JSON format, it should be like Name Value pair and last pair will not end with comma as shown above.
Glad it worked for you. Can you please mark my answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke