- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 02:45 AM
can someone please post the code for the following scenario:
1. How to fetch all the floors from the selected building in record producer form by using the catalog client script through script include.
2. How to check the selected building capacity/quantity of seats. limit the capacity when user tries to select the capacity more then the capacity of the selected building through script include + catalog client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 07:16 AM
Hi @Priyapatnayak ,
Modify script with exact field names and table name
//client callable script include
var buildingSysID=this.getParameter('sysparm_buildingSysID');
getFloors: function() {
var floors = [];
var gr = new GlideRecord('cmn_building');
gr.addQuery('sys_id', buildingSysID);
gr.query();
if (gr.next()) {
var floorRef = gr.floors;
while (floorRef.next()) {
floors.push(floorRef.floor.getDisplayValue());
}
}
return floors;
},
//onchange Client script on building varible
var ga = new GlideAjax('ScriptIncludename');
ga.addParam('sysparm_name', 'scriptincludefunctionname');
ga.addParam('sysparm_buildingSysID', newValue);
ga.getXML(function (response) {
if (response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
//configure the answer as per your requirment
}
Please mark it as helpful and solution proposed if it works for you.
Thanks ,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 07:16 AM
Hi @Priyapatnayak ,
Modify script with exact field names and table name
//client callable script include
var buildingSysID=this.getParameter('sysparm_buildingSysID');
getFloors: function() {
var floors = [];
var gr = new GlideRecord('cmn_building');
gr.addQuery('sys_id', buildingSysID);
gr.query();
if (gr.next()) {
var floorRef = gr.floors;
while (floorRef.next()) {
floors.push(floorRef.floor.getDisplayValue());
}
}
return floors;
},
//onchange Client script on building varible
var ga = new GlideAjax('ScriptIncludename');
ga.addParam('sysparm_name', 'scriptincludefunctionname');
ga.addParam('sysparm_buildingSysID', newValue);
ga.getXML(function (response) {
if (response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
//configure the answer as per your requirment
}
Please mark it as helpful and solution proposed if it works for you.
Thanks ,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 08:04 AM
Hi @Anand Kumar P ,
thanks a lot for the response. If you don't mind please try to help me on second query also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 08:07 AM
Thanks a lot @Anand Kumar P ,
If you don't mind please help me to find out solution for second query also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 11:18 AM
Hi @Priyapatnayak,
In client script add below script
var ga = new GlideAjax('ScriptIncludename');
ga.addParam('sysparm_name', 'scriptincludefunctionname');
ga.addParam('sysparm_buildingSysID', newValue);
ga.getXML(function (response) {
if (response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
var buildingCapacity = parseInt(answer);
var selectedCapacity = parseInt(g_form.getValue('capacity_field'));
if (selectedCapacity > buildingCapacity) {
g_form.setValue('capacity_field', buildingCapacity);
alert('Selected capacity exceeds the building capacity. Capacity has been limited to ' + buildingCapacity);
}
}
});
Please mark it helpful if it works.
Thanks,
Anand