Skip to main content
I need to add an statement into this custom button so that it only runs if it meets a certain, how would I do this?

The statement essentially needs to say if the logged in user is equal to the R_D_Service_Owner__c or the project_owner__c then it can run, or if the logged in user profile equals 'system administrator' it can run, or if the logged in user equals a specific user id, or another specific user id it can run.

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}

var r = new sforce.SObject("Product2");

r.id = "{!Product2.Id}";

r.Convert_to_Service_Catalogue__c = true;

result = sforce.connection.update([r]);

window.location.reload();

if ( result[0].getBoolean( "success" ) ) {

location.reload( true ); // refresh page

} else {

var errors = result[0].errors;

var errorMessages = "The Lifecycle Status must be Beta, and the following fields must be populated; Name, Unique ID, Jisc Directorate, Include in Dashboard, Service/Project Owner or else this record won't be converted to a Service Catalogue record";

for ( var i = 0; i < errors.length; i++ ) {

errorMessages += errors[i].message + '\n';

}

alert( errorMessages ); // display all validation errors

}
1 resposta
0/9000