difference behaviour b/w platform and in portal

nameisnani
Mega Sage

Hi Team , 

 

 

There is a difference behavior between Portal and Platform end . 

 

We have catalog called Lost/stolen device . In that based on device Type - Short description is populating .

 

For example : If i choose device type is 'Laptop' >> In short description field populating like this i.e [ Lost/Stolen Laptop reported By requestor for name

 

For this i have written client script ;

nameisnani_1-1723618930840.png

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var reqFor = g_form.getDisplayValue('requested_for');
    var newvall = g_form.getDisplayValue('device_type'); //replace with the backend name of device type field


    //g_form.setValue('short_description_1', newvall +' '+ ": Device Type " + ' ' + " Reported By " + reqFor);
    g_form.setValue('short_description_1', "Lost/Stolen " + newvall + ' ' + " Reported By " + reqFor);





}

nameisnani_0-1723618340769.png

 

 

Now , the problem I am facing that , this is working fine in portal , when we are checking from the platform , it is not working .

 

If you could see in the below screenshot , in the short description field requestor for name is not populating .

 

nameisnani_2-1723619065777.png

can anyone please help me with this issue , where i have to update in my scirpt please help me , 

 

It should work in platform level also . 

5 REPLIES 5

Slava Savitsky
Giga Sage

According to the documentation, g_form.getDisplayValue('your_field_name') only works in Service Portal. For the Core UI, you need to use this instead:

 

g_form.getDisplayBox('your_field_name').value

 

 

To combine the code for both UIs in one script, you can use the following approach:

var fieldName = 'my_field_name';
var fieldValue = '';

if (window == null) {
    // Service Portal UI
    fieldValue = g_form.getDisplayValue(fieldName);
} else {
    // Core UI
    fieldValue = g_form.getDisplayBox(fieldName).value;
}

@Slava Savitsky 

could you please provide me the update script with me . It will really helps for me 

Try this:

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {
        return;
    }

    var reqFor = '';
    var newvall = '';
	
	if (window == null) {
		// Service Portal UI
		reqFor = g_form.getDisplayValue('requested_for');
		newvall = g_form.getDisplayValue('device_type');
	} else {
		// Core UI
		reqFor = g_form.getDisplayBox('requested_for').value;
		newvall = g_form.getDisplayBox('device_type').value;
	}

    g_form.setValue('short_description_1', "Lost/Stolen " + newvall + ' ' + " Reported By " + reqFor);

}

 

In fact, this is something you should be able to do yourself. If have difficulty making such small changes to client scripts, make sure you get appropriate training.

@Slava Savitsky  

 

Your script not worked out .