Skip to main content
Babu BaDi が「#Data Management」で質問

I have been trying to write a javascript custom button to change the owner and status of the record. Could someone please help? Below is the code.

{!requireScript("/soap/ajax/23.0/connection.js")}

var newpims= new sforce.SObject("Pims__c");

newpims.ownerid = '00GK0000001079k';

newpims.Status__c="Submitted";

var result = sforce.connection.update([newpims]);

if(result[0].success=='true'){

alert('Updated');

location.reload(true);

}

 

 
16 件の回答
  1. 2014年11月17日 17:25

    Damn! Check this out:

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

    try{

    if("{!Pims__c.Status__c}" !== "Submitted"){

    var isContinue = confirm("You're about to Submit the record. Continue ?");

    if(isContinue){

    var pimsToUpdate = new sforce.SObject("Pims__c");

    pimsToUpdate.Id = "{!Pims__c.Id}";

    pimsToUpdate.Status__c = "Submitted";

    pimsToUpdate.OwnerId = "00GK0000001079k";

    var result = sforce.connection.update([pimsToUpdate]);

    if(result[0].success === "true"){

    location.reload();

    }

    else{

    alert(

    "An Error has Occurred. Error: \r\n" +

    result[0].errors.message

    );

    }

    }

    }

    else{

    alert(

    "This record has already been Submitted!"

    );

    }

    }

    catch(e){

    alert(

    "An unexpected Error has Occurred. Error: \r\n" +

    e

    );

    }

0/9000