If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Thanks Chuck




Hi Amlan,



Have we answered your question on this one?



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Anyone been able to get this client script working on a createNow/scoped application?

 

I see this error:

onChange script error: TypeError: $ is not a function function () { [native code] }

 

In the script i have replaced the lines with 'incident.caller_id' for 'x_spog_travel_traveller.u_traveller'

Inspected the field the names were actually to check the id names, they are:

label.x_spog_travel_traveller.u_traveller

sys_display.original.x_spog_travel_traveller.u_traveller

 

function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.x_spog_travel_traveller.u_traveller');
var callerField = $('sys_display.x_spog_travel_traveller.u_traveller');
if (!callerLabel || !callerField)
return;

if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('u_traveller', vipCallerCallback);
}

function vipCallerCallback(caller) { // **my field name is Passenger, does this need to be passenger? tried but didn't work either
var callerLabel = $('label.x_spog_travel_traveller.u_traveller').down('label');
var callerField = $('sys_display.x_spog_travel_traveller.u_traveller');
if (!callerLabel || !callerField)
return;

//check for VIP status
if (caller.vip == 'true') { // **
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";

callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}

Swapnil Bhakar1
Mega Guru

Hi Amlan Pal,



Write onchange client script:



Table : Incident


Type: onChange


Field Name: Assigned to



Script: Copy and paste below script,don't make any changes



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


  var callerLabel = $('label.incident.assigned_to');


  var callerField = $('sys_display.incident.assigned_to');


  if (!callerLabel || !callerField)


  return;



  if (!newValue) {


  callerLabel.setStyle({backgroundImage: ""});


  callerField.setStyle({color: ""});


  return;


  }


  g_form.getReference('assigned_to', vipCallerCallback);


}




function vipCallerCallback(caller) {


  var callerLabel = $('label.incident.assigned_to').down('label');


  var callerField = $('sys_display.incident.assigned_to');


  if (!callerLabel || !callerField)


  return;



  //check for VIP status


  if (caller.vip == 'true') {


  var bgPosition = "95% 55%";


  if (document.documentElement.getAttribute('data-doctype') == 'true')


  bgPosition = "5% 45%";



  callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });


  callerField.setStyle({color: "Red"});


  } else {


  callerLabel.setStyle({backgroundImage: ""});


  callerField.setStyle({color: ""});


  }


}



Hope it will help you.



Regards,


Swapnil



PS: Hit like, Helpful or Correct depending on the impact of the response