anyway to force the URL Padlock to unlock then lock automatically?

Kiwipedro
Mega Contributor

Hi all,
I have written a very simple client side script in order to append the service tag of any Dell PC onto the dell warranty URL.

The idea being that rather than having to keep all the info about the computer within service-now, you can keep basic info and link off to Dell's website for a more detailed view (duplication of data = bane of everyone's existence).

The problem is that the URL does not appear until you click on the locked padlock and then click on the unlocked padlock to "lock" the link. I've tried changing the UI Properties option "Unlock empty URL fields on form load" and all this does is the same as clicking on the intially locked padlock. You still have to click on the padlock and save the changes before the URL is "clickable".

What I want to do is to have it locked in everytime you open the record. Not sure if this should be a business rule, or if its necessary to keep it as a client script.

What I've done:

Created a new table (extended from cmdb_ci_computer) called u_Dell_Computers

Populated the serial_number field with the Dell Service Tag.
Created a URL Field called 'u_original_config__warranty_in'
Created the following onLoad client-side script.
function onLoad() {
var dellurl = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&s...";
var serialn = g_form.getValue('serial_number');
g_form.setValue('u_original_config__warranty_in', dellurl + serialn);
}

The bodge way would be to add a script line that can unlock, then lock the URL padlock, but if someone out there knows of setting to fix this....?

Thanks for your attention
KP

1 ACCEPTED SOLUTION

Actually ended up using a UI Action and a Button on the top of the Form
Here's the script that runs:

function DellConfWar() {

var dellurl = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&servicetag=";

var serialn = g_form.getValue('serial_number');

dellurl = dellurl + serialn;

var rcwin = window.open(dellurl, 'Dell_Warranty_Page', 'fullscreen=yes');

}



View solution in original post

6 REPLIES 6

Mark Stanger
Giga Sage

I realize you've already got an answer on this one, but I figured I'd post the client script to lock/unlock a URL field here just in case anybody else needs it in the future.

This client script will lock/unlock a url field called 'u_url' on the incident form when the 'incident_state' field changes. To make it work with your fields you'll need to modify the script accordingly.



function onChange(control, oldValue, newValue, isLoading) {
if(newValue == 6){
//Incident state is 'Resolved' so lock the URL field
lock(gel('incident.u_url_lock'), 'incident.u_url', 'incident.u_url', 'incident.u_url_link', 'incident.u_url', 'incident.u_url_link');
}
else{
//Unlock the URL field
unlock(gel('incident.u_url_unlock'), 'incident.u_url', 'incident.u_url', 'incident.u_url_link');
}
}


Mark Stanger
Giga Sage

Just created a post that has this example and other examples for glide_list fields and custom lock icons in other places in the app.

http://www.servicenowguru.com/scripting/client-scripts-scripting/lock-unlock-glidelist-url-fields-client-scripts/