Populate catalog item fields from the values stored in a custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 05:12 AM
I have a catalog item with a date field and another text field.
The requirement is that when a requestor opens the catalog item then based on the date field value it should fetch the values from another table that contains this data for the requestor.
for example, the table "ABC" has the following data stored.
Username = "Test User"
Date = 31-08-2022
ID = 123
so what is needed is that when the requestor "Test User" opens the catalog item and selects the date as 31-08-2022 the other fields on the catalog item should populate the values stored in the table ABC for this date and this user.
so if the requestor selects the date 31-08-2022 the field u_ID on the catalog item should auto-populate from the ID field in the ABC table.
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 12:40 AM
Hello
Did you get chance to look into solution provided by me. Please let me know if you need any help.
Regards,
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 03:00 AM
Hello
Apologies for the delay in response.
I tried the solution provided by you and unfortunately it didn't work for me.
I will share the details with you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 03:05 AM
Hello
So I have a custom table with the information stored with the date and username ( see attachment capture.png).
So on the portal when a user selects a date it should populate the data looking up from a custom table against the username ( see attachment capture1.png).
I tried with your script include and an onChange client script but it's not working, maybe I am missing something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 05:42 AM
Hello
Have to checked logs if script include is being call correctly also what exactly value is returning from script include in the alert [alert("current date" + answer);]
Also what is variable type of variable "id" where we setting the value? I considered it as single line text.
Kindly share both scripts so I can help you.
Regards,
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 05:54 AM
Alert is returning current date null.
The variable is a reference type, and this is only one field i need to populate other fields also as shown in the screenshots but i wanted to test it on one field first.
Script Include
var dateformat = Class.create();
dateformat.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getdate: function() {
var req = this.getParameter('sysparm_req');
var date = this.getParameter('sysparm_date');
//gs.log('date ' + date + ' requested ' + req);
var gd = new GlideRecord('x_sosb_fico_time_c_recorded_on_entries');
gd.addQuery('u_name', req);
gd.addQuery('u_date_day_1', date);
gd.query();
if (gd.next()) {
var id = gd.u_ssp_code_1;
}
return id;
}
});
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var request = g_form.getValue('name');
var date = g_form.getValue('date_day');
// alert('date ' + date + ' requested ' + request);
var ajax = new GlideAjax('dateformat');
ajax.addParam('sysparm_name', 'getdate');
ajax.addParam('sysparm_req', request);
ajax.addParam('sysparm_date', date);
ajax.getXMLAnswer(setAnswer);
function setAnswer(answer) {
alert("current date" + answer);
g_form.setValue('ssp_code', answer);
}
}