You need to sign in to do that
Don't have an account?
bmartinez76
S-Control for Opportunity Object
Hello everyone. I am new to these boards and to S-Controls. I am not a programmer per say,but I have been assigned to role of admin for my company. I have so far done a great job setting up the objects and creating simple formulas and validation rules. I am now trying to create a process in the opportunity tab that will fetch the renewal billing month from the account object and place it in the opportunity renewal billing month field. So when entering an opportunity, the person would look up the company and then once selected the S-Control would search the account object for that company and retrieve the renewal billing information and paste it on the opportunity. I was told that an S-Control can achieve this. If anyone can lead me in the right direction it would be greatly appreciated. Thank you in advance.
Code: The behavior for this button should be "Execute JavaScript" so that Salesforce knows it should run your code (instead of sending the user to a new page or something). Now, all you need to do is add the button to your page layout, and you're ready to go. I did the fields from memory, so you might need to check the field names.
~ sfdcfox ~
I read the coding here before attempting to create the button so I could better understand what I was doing. Since I really only wanted to retrieve the renewal month field from the account object I removed the other fields (Billing City,State, Etc) you initially added to the coding. I created this button in the opportunity object and set it up as a detailed button to add to my admin page layout so no one but me would see it. I created an opp and then saved it and tried my custom button but got the following error below:
"A problem with the OnClick Javascript for this button or link was encountered: Expected ‘(‘"
Is there anyway to incorporate this button when you click on new opportunity to replace the save or save & new button so that the users will be forced to retrieve this data before saving? Or will the users be forced to click on the custom button after creating the opportunity to populate the data?
Thank you for your help in advance as it is very much appreciated.
Coding used in button:
{!RequireScript("/soap/ajax/9.0/connection.js")}
function updateOpportunity()
{ if("{!Opportunity.AccountId}" == "") // They didn't select an account!
return
// Get the account billing information.
Account = sforce.connection.retrieve("Renewal Month","Account",["{!Opportunity.AccountId}"])
// Create an object to represent the opportunity.
Opportunity = new sforce.SObject("?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Opportunity"]
// Populate the ID and the fields we're updating.
Opportunity["Id"] = "{!Opportunity.Id}"
Opportunity["BRenewalMonthB__c"] = Account["Renewal Month"]
// Try to update the opportunity.
sforce.connection.update([Opportunity])
// Refresh the page.
window.top.location.href=window.top.location.href
}
try // As in, try to update the opportunity.
{ updateOpportunity()
} catch(e) // Catch any errors.
{ // Show the error to the user.
alert("Error: "+(e.faultCode?e.faultCode:e.message?e.message:e)+
"\n\nPlease contact your administrator in regards to this error.")
}