You need to sign in to do that
Don't have an account?
Lukdan
S-control in Opportunity Page Looping
I'm totally new to scontrols and java. I'm trying to insert this code right into the opportunity so it runs on page load and only once.
To stop the loop, I need an if statement placed inside comparing the 2 fields involved, but having no success...any suggestions on how or where to insert? Thanks in advance...
IF Code:
Main Code:
To stop the loop, I need an if statement placed inside comparing the 2 fields involved, but having no success...any suggestions on how or where to insert? Thanks in advance...
IF Code:
string Projecttext = "{!Opportunity.Project_Text__c}"; string Project = "{!Opportunity.Project__c}"; if ( Projecttext != Project ) {
Main Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title> <script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script> <script language="javascript"> <!-- function init() { sforceClient.registerInitCallback(doit); sforceClient.setLoginUrl("https://www.salesforce.com/services/Soap/u/7.0"); var ir = sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true); } function goBack(Id) { var r = "{!Scontrol.URL}".split(/salesforce.com/); var whichId = ""; if (Id != null) whichId = Id; var returnUrl = r[0] + "salesforce.com/"+whichId; window.parent.parent.location.href = returnUrl; } function doit() { var myCase = new Sforce.Dynabean("Opportunity"); myCase.set("Id", "{!Opportunity.Id}"); myCase.set("Project_Text__c", "{!Opportunity.Project__c}"); var saveResults = sforceClient.Update(myCase)[0]; if (Sforce.Util.dltypeof(saveResults) != "SaveResult" || saveResults.success == false ) { alert("Error updating Case " + saveResults); } goBack("{!Opportunity.Id}"); } </script> </head> <body onLoad="init();"> Updating Project Text.... </body> </html>
Thanks for your response. The field I'm copying with the scontrol is a lookup to a custom object. If I copy the field using the update feature (I did try this first), the field value is actually the ID (link) of the custom object and not the name. The scontrol grabs the actual text value of the name and pastes it into the second field. I want this to happen without the user clicking a custom link or button, which is why I am trying to put it directly into the opportunity page layout so it happens during the page load. Ultimately I want to validate this name to contain a certain phrase. Is there a way to place the if statement within the scontrol code so it only runs if the 2 fields differ?
then in your scontrol, you check for $Request.didFieldCopy ( $Request is a special merge field , look it up)
if didFieldCopy is true, you don't do the calc again.