You need to sign in to do that
Don't have an account?
S-Control help needed with Updating a custom field in Opportunity with a custom field in Accounts
<script type="text/javascript" src="/soap/ajax/9.0/connection.js" > </script>
<script type="text/javascript" >
var AccountDetails = sforce.connection.query("select Company_Number__c from Account where Name = '{!Opportunity.AccountId}'");
var AccountArray = AccountDetails.getArray("records");
var OpportunityRec =new sforce.SObject("Opportunity");
OpportunityRec.Id="{!Opportunity.Id}";
if(AccountDetails.size >0 {
OpportunityRec.Account_Number__c = AccountArray[0].Company_Number__c;
if(sforce.connection.update([OpportunityRec])[0].getBoolean("success"))
{
window.parent.location.href="{!URLFOR($Action.Opportunity.View, Opportunity.Id, null,true)}";
}
else
{
alert("Problem in Updating the Company Number from Account to Opportunity"); }
}
</script>
Your help is appreciated!
Thanks, that worked! Just curious though, any pointers on what is wrong with my coding?
Thanks again
I think where you might be failing is your first SOQL statement
select Company_Number__c from Account where Name = '{!Opportunity.AccountId}'
I think the problem may be stemming from your condition where you are comparing the NAME of the company with the Account ID from the opportunity. You should probably get no results returned from that.