Need to help to populate cmdb ci storage server fields in hardware assest table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-18-2022 01:03 AM
Hi All,
I have a requirement that we have 3 fields in cmdb Ci storage server table. Those are primary contact , secondary contact and responsible manager fields.
These three fields I need to populate on alm_hardware table.
For this I have created 3 new fields but when I need to write script include and call it in onload clientscript.
Can you please help me on this how to write script include and onload client script.
- Labels:
-
Cost Management (ITSM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-18-2022 01:23 AM
SCRIPT INCLUDE:
functionname: function() {
var obj = {};
var param = this.getParameter("value from client script")
var gr = new GlideRecord("tablename");
gr.addQuery("variable",param);
gr.query();
if (gr.next()) {
obj.primary_contact = gr.primary_contact.toString();
obj.secondary_contact = gr.secondary_contact.toString();
obj.responsible_manager = gr.responsible_manager.toString();
}
var json = new JSON();
return json.encode(obj);
},
Client script:
function onLoad() {
var ga = new GlideAjax('scriptinclude name');
ga.addParam('sysparm_name','functionname');
ga.addParam('sysparm_variable', passvariable);
ga.getXML(functionanme);
function functionanme(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var parseData = JSON.parse(answer);
g_form.setValue("primary_contact", parseData.primary_contact);
g_form.setValue("secondary_contact, parseData.secondary_contact);
g_form.setValue("responsible_manager", parseData.responsible_manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-15-2022 01:29 AM
hi zeeshan,
Script is working but in list view those fields are not displaying.
Can I use a business rule for this or else in default value of each field in target table how can I call the script include.
Could you please suggest me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-15-2022 08:34 PM
Click on personalise list> select those fields in slush bucket .
Now you can see in list view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-15-2022 08:42 PM
Hi prashant
That I was done but the values are not populating on list view.
Is there any idea to show those values on list view also.