function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mnoorgatmnoorgat 

scontrol and custom object

Hi,

I have managed to attain the dreaded "Error: Formula is too big to execute" error in a formula (number) field in salesforce.  Basically all I want to do is add together some custom fields - each of which do a calculation of their own (hence why I reach the error).  One of the ways suggested to me (and the direction in which I wish to proceed) is to do the calculation via an scontrol.  Essentially what I need to do is this:

{!Q1_score__c} + {!Q2_score__c} + 15 more fields...

...and store the results in {Total_score__c}

I should note that I have no experience relating to the use of scontrol, apart from the fact that I've gathered that I probably need to add C:\Program Files\salesforce.com\OfficeToolkit\2.0\SF_MSApi.dll into the files part when creating an scontrol.

Any assistance will be gratefully received.

Kind regards,

MNoorgat

DevAngelDevAngel

Hi mnoorgat,

The office toolkit is not the answer, the AJAX toolkit is.  To start with, you will need to create an scontrol with javascript that looks kind of like this

 

var sum = {!Q1_score__c} + {!Q2_score__c} + 15 more fields..;

Then using the AJAX toolkit, you can update the record from when you came and then return to that record's page.

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");

var myObj = new DynaBean("myobject");

myObj.set("id", "{!MyObjectId_ID}");

myObj.set("TotalScore__c", sum):

sforceClient.Update([myObj]);

document.parent.location.href = "{!MyObject_Link}";

 

mnoorgatmnoorgat

Dave,


Thank you for your reply.


Just to check, do I need to put all that between the:


[script type="text/javascript"] and [/script] tags? (where brakets become <>)


Also, was I right when I said (as otherwise I'm not sure what I'm meant to put in the "file" section when creating an scontrol):


"I've gathered that I probably need to add C:\Program Files\salesforce.com\OfficeToolkit\2.0\SF_MSApi.dll into the files part when creating an scontrol."


Thank you for your help.

Message Edited by mnoorgat on 10-23-2005 02:31 PM

mnoorgatmnoorgat

Dave,


Please ignore my last message, I realise now the "Bad Link Definition" error wasn't caused by me not having to include a file but by something else.


The something else is what I need help with.


I've been trying to do as you suggested but I keep getting the "Bad Link Definition" error when I try to save my code having added the following line to one of my functions:


 var score = {!Average_EHA_Score__c};


When I remove that one line it saves fine, but when I add it I get the error.
Currently my scontrol looks like this:
[html]
 [head]
   [title]Calculating Average Scores[/title]
   [script src="
https://www.sforce.com/ajax/beta1/sforceclient.js" type="text/javascript"][/script]
   [script language="javascript"]
[!--
//Page initialization is a good idea. 
function initPage()
{
  sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
  window.setTimeout(";", 1000);
  calculateTotal();  
}


function calculateTotal()
{
  var score = {!Average_EHA_Score__c}; // Error when I add this line
 
 // the rest of my code
}
//--]
   [/script]
 [/head]
 [body onload="initPage();"]
 [/body]
[/html]


Any ideas what I'm missing?


Regards

Message Edited by mnoorgat on 10-23-2005 02:32 PM

mnoorgatmnoorgat
Hi,

Finally figured it out.

The {!Average_EHA_Score__c} should have been {!Screening_Average_EHA_Score}. I didn't realise the merge field definition was different to the field name.

I have another problem now, but I'm going to perservere a bit longer before bothering everyone again.

Kind regards,

Message Edited by mnoorgat on 10-23-2005 02:31 PM

mnoorgatmnoorgat
Dave,

Quick question, what exactly does this do?

document.parent.location.href = "{!Screening_Link}";

I thought it would change the page back to the detail page, but I can't get it to work.

Regards,
FinTechFinTech
Is it possible to update a checkbox from the calling page?