You need to sign in to do that
Don't have an account?

javascript button
hi! can you help me?
i have a javascript button that i made to modify the owner id if the Business_unit__c field is not null.
Doesnt work.. :(
this is the code
{!REQUIRESCRIPT
("/soap/ajax/13.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Case)};
var newRecords = [];
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Case");
c.id = records[n];
var efdata = sforce.connection.query("Select Business_unit__c From case where id = " + "'" +c.id + "'" );
if(efdata == null){
alert("O caso está incompleto! Dados em falta: Business Unit");
}else{
var efdata2 = sforce.connection.query("Select User_logged__c From case where id = " + "'" +c.id + "'" );
for (var i=0; i<efdata2.length; i++) {
c.ownerId=efdata2[i];
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
}
}
Do you need to still set the session ID/URL for access?
tks joshbirk :) i had solved today !many tks
I was going throug your post and reworked (reorganized) on the code and then realized you solved the issue(which is very good). Thought I would still post some of my observations (just in case if this helps)
many tks :)
always helps - learning other ways to thing :)