2.2.difference behaviour b/w platform and in portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2024 07:26 PM
Hi Team ,
There is a difference behavior between Portal and Platform ends.
We have catalog called Lost or Stolen Device. Based on device type, a Short description is populating .
For example, if I choose device type is 'Laptop' >> In short description field, it is populating like this, i.e. [ Lost/Stolen Laptop Report] [By requestor for name ]
For this, i have written client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var deviceTypeValue = g_form.getValue('device_type');
g_form.getReference('requested_for', function(requestedForRecord) {
var requestedForValue = requestedForRecord.name;
g_form.setValue('short_description_1', "Lost/Stolen " + deviceTypeValue + ' ' + " Reported By " + requestedForValue);
});
}
Now , the problem I am facing is that this is working fine in portal, but when we are checking from the platform , it is not working .
If you could see in the below screenshot ,from the portal and platform in the short description field, Device Type backend name is showing instead of label .
Portal View
Platform view
The Result should come like this
In both Platform and in portal .
can anyone please help me here , what changes should i need to do in my script .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2024 07:39 AM
Can you give alert and check code seems to be correct ..
I am re-writing the script.. make sure backend name is correct. I tested in Personal Instance its working.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var deviceTypeValue = g_form.getValue('device_type');
alert('Device Type Value:', deviceTypeValue);
var deviceTypeLabel = '';
switch (deviceTypeValue) {
case 'mobile_phone':
deviceTypeLabel = 'Mobile Phone';
break;
case 'laptop':
deviceTypeLabel = 'Laptop';
break;
case 'other_specify_desp':
deviceTypeLabel = 'Other - Specify in Description';
break;
// Add more cases as needed
default:
deviceTypeLabel = 'Device';
}
alert('Device Type Label:', deviceTypeLabel);
g_form.getReference('username', function(requestedForRecord) {
if (requestedForRecord) {
var requestedForValue = requestedForRecord.name;
alert('Requested For:', requestedForValue);
g_form.setValue('short_description_1', "Lost/Stolen " + deviceTypeLabel + ' Reported By ' + requestedForValue);
} else {
alert('No record found for username.');
}
});
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2024 08:14 PM
Hi @Ravi Gaurav
This is the script I have tried which u have given , alerts i commented
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var deviceTypeValue = g_form.getValue('device_type');
//alert('Device Type Value:', deviceTypeValue);
var deviceTypeLabel = '';
switch (deviceTypeValue) {
case 'mobile_phone':
deviceTypeLabel = 'Mobile Phone';
break;
case 'laptop':
deviceTypeLabel = 'Laptop';
break;
case 'other_specify_desp':
deviceTypeLabel = 'Other - Specify in Description';
break;
// Add more cases as needed
default:
deviceTypeLabel = 'Device';
}
//alert('Device Type Label:', deviceTypeLabel);
g_form.getReference('username', function(requestedForRecord) {
if (requestedForRecord) {
var requestedForValue = requestedForRecord.name;
//alert('Requested For:', requestedForValue);
g_form.setValue('short_description_1', "Lost/Stolen " + deviceTypeLabel + ' Reported By ' + requestedForValue);
} else {
//alert('No record found for username.');
}
});
}
Still it is not working .
If you could see here short description is blank here .