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
sgoremasgorema 

Scontrol Performance question

I have created an scontrol in javascript that clones an opportunity and closes out the current oppty. It clones about 35 fields on the oppty record as well as any line items and any contact roles.
 
The whole process is taking about 16 seconds to run. So I started taking out my queries (to get account name (for use in oppty name), line items and contact roles) one by one to see how much they were slowing things down. What I saw was that even with no queries it was taking 8 seconds and then each of the queries added about 3 seconds each.
 
I am wondering if this is normal response time? If I should paste my code here for people to see then let me know. I am new to javascript and so perhaps there is something that I could be doing differently. Any help would be great!
 
Also - Is there a way to display on the screen something like 'Creating Renewal Oppty. Please Wait....' while it is doing all of the processing?
 
thanks!
michaelforcemichaelforce
I am new myself, but I can at least offer two things I have learned thus far...  1) Since you have the Account ID you should use 'retrieve' to get the name instead of 'query' as it will be faster.  2) If you (like i do) are testing your s-control from your desktop as oppose to pasting into salesforce each time you want to rerun and logging in with the following:
 
Code:
var loginresult = sforceClient.Login("username","password");
 
Then this line alone will take approx 4 seconds.
 
Hope this helps.
steph1sourcesteph1source

Thanks for your reply. I am not sure how I would use Retrieve. I am currently using the following query to get the account name:

var accntqr = sforceClient.Query("Select Name from Account Where Id = '{!Opportunity_Account_ID}'");

How could I use Retrieve here? I tried replacing Query with Retrieve and that did not work.

 

michaelforcemichaelforce
Here is an example: Code:
var result = sforceClient.retrieve("Name, District__c", "Account", id_array);
 
You should definitely review the API 7.0 Documentation... or if you're a dork like me, print them out and put it in a binder.  Even though there are no coded examples that apply directly to javascript / AJAX it still explains all the calls you can make, input and return arguments, limitations, usage guidance, etc.