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
dev_jhdev_jh 

Executing API calls as another user

Hi all,

There is an interesting S-Control in the Apexchange to create a link and update the company´s currencies, it is called Currency Exchange Rate Updater 1.0.

We want to use it in our organization, the problem is that we want a user with no Admin rights to execute it and the Date Conversion data, for some odd reason, requires this priviledges.

The question is if it is possible to execute API calls as a different user to overcome this limitation and have the code execute successfully by specific users. Here is the code in question (an extract of it) in case it helps clarify:

Code:
        var newConversionRate = new sforce.SObject("DatedConversionRate");
        newConversionRate.IsoCode = isoCurrencyCode;
        newConversionRate.ConversionRate = roundRate;
        newConversionRate.StartDate = today;
        //insert the record into SFDC
        try {
          var newConversionRateResult = sforce.connection.create([newConversionRate]);

 Thanks,

J

aalbertaalbert
You could re-write this to use Apex. You can call an Apex Web Service from an SControl using the AJAX Proxy.


To expose an apex method as a web service: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_web_services_methods_exposing.htm


To call an apex method through the ajax proxy: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_and_ajax.htm



dev_jhdev_jh
Many thanks Albert, I will give it a go!
TimAlsopTimAlsop
We tried to re-write this app in apex, but we found that the apex code is not allowed to write to the currency objects in salesforce. it seems that this is only possible via the salesforce api, which is not ideal. Do you know a way around this ?
Splashgordon1Splashgordon1

Hi dev_jh.  I have a related question to this... I am trying to use the original Salesforce Labs Currency Updater that you refer to but I cannot get it to work.  We have Advanced Currency Management switched on and every time I click the link to update the currencies, I get a SFDC login screen and cannot progress further.  Did you manage to overcome this?

 

I administer and org where we have around 80 currencies so getting this to work will be a real bonus!  Any help you can provide would be greatly appreciated.

 

Cheers,

Gordon 

dev_jhdev_jh

Hi Gordon,

 

The script worked for me perfectly fine (when run by a user with the proper rights). I can only suggest you log a call with SF to try to get your specific issue resolved. Best of luck,

 

J