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-20-2024 08:29 PM
Hi @nameisnani ,
getvalue always returns the internal name of the choice, it may be the case that for laptop the internal and display value is same and for mobile it is different.
To get the display value of selectbox on portal try this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 11:44 PM
Hello isani,
Please use the below code it will work.
First of all we can't use getDisplayValue () in client script so, Use the below and mark help and accept the solution.
you have to use case wise basis like the below:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var deviceTypeValue = g_form.getValue('devicetype');
var deviceTypeLabel = '';
switch(deviceTypeValue) {
case 'mobile_phone':
deviceTypeLabel = 'Mobile Phone';
break;
case 'laptop':
deviceTypeLabel = 'Laptop';
break;
// Add more cases as needed
default:
deviceTypeLabel = 'Device';
}
g_form.getReference('username', function(requestedForRecord) {
var requestedForValue = requestedForRecord.name;
console.log('Requested For:', requestedForValue);
g_form.setValue('short_descr', "Lost/Stolen " + deviceTypeLabel + ' ' + " Reported By " + requestedForValue);
});
}
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 02:27 AM
Hi @Ravi Gaurav ,
I have made changes in my script
'@Ravi Gaurav I don't know what was mistake here . not working as per my requirement . please help me here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 03:42 AM
share your script please !!
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 04:47 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var deviceTypeValue = g_form.getValue('device_type');
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'
// Add more cases as needed
default:
deviceTypeLabel = 'Device';
}
g_form.getReference('username', function(requestedForRecord) {
var requestedForValue = requestedForRecord.name;
console.log('Requested For:', requestedForValue);
g_form.setValue('short_description_1', "Lost/Stolen " + deviceTypeLabel + ' ' + " Reported By " + requestedForValue);
});
}