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

S-Control to create new record in custom object upon saving Opportunity
Hello everyone.
I am in need of some help creating a S-Control. I am the Admin for my company but do not have much programming experience. I am trying to create a process in the opportunity tab that will create a new record in in a related custom object when the user saves a new opportunity. The new record on the custom (related) object will contain data from 3 fields in 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,
sfmoose
I am in need of some help creating a S-Control. I am the Admin for my company but do not have much programming experience. I am trying to create a process in the opportunity tab that will create a new record in in a related custom object when the user saves a new opportunity. The new record on the custom (related) object will contain data from 3 fields in 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,
sfmoose
my approach would be to embed an scontrol in the opportunity detail page. once the user saves the opportunity, he/she is directed to the opportunity's detail page, which would launch the scontrol. the scontrol would be coded to set the custom object fields based on the opportunity merge fields.
if you need any additional information for the solution above, let me know.
i'm sure there are other solutions, but they escape me currently. perhaps others could chime in?
Do you have any sample code you could send? I'm not sure how to embed the code on the page or how to pull in the opportunity fields to my custom object. I found out from SF that I can't override the Save button which was my original plan.
- Rick Greenwald
Developer Evangelist
for unlimited edition only, correct?
- Rick Greenwald
Developer Evangelist
Any ideas on how I can accomplish this as easily as possible in the meantime? Even some 'starter' s-control code would be much appreciated!!
Hope this helps.
- Rick Greenwald
Developer Evangelist
<html>
<head>
<link href="/sCSS/8.0/1171411121000/Theme2/default/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<script src="/soap/ajax/8.0/connection.js"></script>
<script>
function initPage() {
function findAccount(name) {
result = sforce.connection.query("Select Id from Custom_Object__c where Name like '" + name+ "' limit 1");
return result.size != 0;
}
function createAccount() {
var account = new sforce.SObject("Custom_Object__c");
account.Opportunity__c= "{!Opportunity.Id}"
account.Name="{!Opportunity.Name}"
result = sforce.connection.create(new Array(account));
status = result[0].success == "true" ? "Account created" : "Failed to create account.";
}
try {
if (findAccount("{!Opportunity.Name}")) {
alert("Record already exist. Not creating new ones.");
} else {
createAccount();
}
return false;
} catch (fault) {
sforce.debug.display(fault);
}
}
</script>
</head>
<body bgcolor="#F3F3EC" onload="initPage();">
</body>
</html>
I dont know your post helped 'sfmoose' or not. It Helped me. I have learnt new things from your post. Thanks!