You need to sign in to do that
Don't have an account?
Editing account data
Hi all,
I call an external web service and I would like to write the answer into an account's field.
By now I'm able to do the callout and I get the response and to edit account's field I use a query. But I'm forced to use a particular name of the account.
The cose is the following:
String r = np.GetPrimeNumbers(8);
String varName = 'Test triggerB';
Account[] la = [select Name, Phone, Fax, Account_Credit_Check__c from Account where name = :varName];
I'm forced to use Test triggerB as account name. How can I call the field account name, instead of its value?
See that makes things much easier now
sforce.apex.execute( ("ExpWsNumeriPrimi", "recuperaNumeriPrimi",{AccountId:"{!Account.Id}"});
And you'll have to update your method to take in the AccountId, methodName ( Id AccountId )
All Answers
I don't think I quite follow what you're asking for.
What kind of answer does your webservice return? And what are field you planning to write into the account? And how do you know which account to write to?
web service resturns a string. For example I would like to write the string value into account's phone field.
How can I do this?
Account a = new Account(Id='whatever the accounts id is');
a.phone = theResultOfYourWebServiceCall;
update a;
Thanks a lot!
But what if I have an already exiting account?
I create an account in Account tab. Then by a function button I make a callout to an exetrnal Web Service that returns account's phone number. Now I need to edit the field phone number for the already exsiting account. How can I do it?
I'm trying to biuld up a code that updates a generic account. I need to know if there's a way to get the account id, from an existing record. I don't want to write account id in the code, but from a code line I want to get an account id.
How do I get the account id if I don't know it?
This is my code. Line 8 is the way that I'm using now: I put a fixed value into a variable. Line 9 shows you what I would like to do: use a method to get account name (or id).
Is line 9 correct? What should I have to use?
Thanks once more!
See this is the part where I'm confused. I understand that you wanted to update a field on the Account, but you don't know which Account you want to update, or at least you don't seem to have a starting point on figuring out which Account to use.
My question to you is now, how is being called? or where is it being called from?
One of the things you can do is pass in the Account OR the Account ID into your method call "recuperaNumeriPrimi( Account a )" and you can refer to the variable "a" in your method, thus avoiding having to do a query call in your method to get details of the Account.
But like I said, it depends on how you are calling this method... does the caller of the method know what the Account is?
that's the point.
i call this class by a custom button from a generic account layout.
so i wish to have a method, or a way to pass the account detail (name or Id could be the same) to my class.
I am in the details page of the Account Jhon Doe.
how can i pass the account ID if this is the custom button funtion?
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} sforce.apex.execute("ExpWsNumeriPrimi", "recuperaNumeriPrimi", {});
See that makes things much easier now
sforce.apex.execute( ("ExpWsNumeriPrimi", "recuperaNumeriPrimi",{AccountId:"{!Account.Id}"});
And you'll have to update your method to take in the AccountId, methodName ( Id AccountId )
Ok,everything is going right!
Thanks a lot!
Ciao!!