1

I have a button that does a couple of field updates. I would like to add a third field update that would only fire based on a formula. That is - IF( RecordtypeID = "#", Checkbox3__c = TRUE, NULL ) Can anyone help with the syntax? This is the button:

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

try { 
    var newRecords = []; 
    var c = new sforce.SObject("Object__c"); 
    c.id ="{!Object__c.Id}"; 
    c.Checkbox1__c = true; 
    c.Checkbox2__c = true; 
    newRecords.push(c); 
    result = sforce.connection.update(newRecords); 

    if( result[0].getBoolean( "success" ) ) { 
        window.location.reload(); 
    } else { 
        alert( "An error has occurred. Error:" + result ); 
    } 
} catch( e ) { 
    alert( "An unexpected error has occurred. Error:" + e ); 
}
0

1 Answer 1

0
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} 

try {
    var selectedRecords = sforce.connection.query("SELECT Id, RecordTypeId from Object__c where Id ='{!Object__c.Id}' limit 1");
    var records = selectedRecords.getArray("records");
    var record = records[0];
    record.Checkbox1__c = true; 
    record.Checkbox2__c = true;
    if(record.RecordTypeId == '00Q0q00000176Fd'){ //paste here your recordtype id 
        record.Checkbox3__c = true;
    }
    var updateRecords = [];
    updateRecords.push(record); 
    var result = sforce.connection.update(updateRecords); 
    if( result[0].getBoolean( "success" ) ) { 
        window.location.reload(); 
    } else { 
        alert( "An error has occurred. Error:" + result ); 
    } 
} catch( e ) { 
    alert( "An unexpected error has occurred. Error:" + e ); 
}

don't forget to replace '00Q0q00000176Fd' in condition with your recordtype id

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .