You need to sign in to do that
Don't have an account?
Felix Jong Seok Chae
AccountID and AccountName in REST
I am trying to insert a new Case record in salesforce, so I created the REST in Java for that.
In both the APEX developer console and a inserting method in REST I use the field AccountID, but
in Salesforce website I have to choose string-typed name of a company for the field Account Name.
I also checked all possible fields for the case object in developer console and I didn't see AccountName field. However, when I used a specific ID (picked a random one from developer console) for AccountID in REST, the newly created case record acquired the Account Name associated with that Account ID. Is there a way to use Account Name direclty from REST instead of using AccountID?
In both the APEX developer console and a inserting method in REST I use the field AccountID, but
in Salesforce website I have to choose string-typed name of a company for the field Account Name.
I also checked all possible fields for the case object in developer console and I didn't see AccountName field. However, when I used a specific ID (picked a random one from developer console) for AccountID in REST, the newly created case record acquired the Account Name associated with that Account ID. Is there a way to use Account Name direclty from REST instead of using AccountID?
You have no need to sent the Account.Name from your REST API. It is Salesforce Standard, if there is a lookup field on any object, then you need to set record id in it and it will show you the Name of that record. It is Salesforce Internal process.
Account is an Lookup field with AccountId Api name on Case. So only set account id. For more detail you need to study about Salesforce fields and object.
Please mark it best answer if you are satisfied.
Have a nice day!!
For example, let's say I would like to add account field like Paypal. How should I choose the accountID associated with this account field?
You have 2 options here:
1) You need to create a custom field on Case with name Account Name (Account_Name__c will be the api name). Use this api name to put the Account Name. Now à Need to create a trigger in Salesforce which will search Account Id on behalf of Account Name automatically and add that id in AccountId lookup field.
2) Query on Account object first get the Id on behalf of Name and now use this Id in your callout like this.
Account objAcc = [Select Id, Name from Account Where Name = ‘Paypal’];
Now Use
objCase.AccountId = objAcc.Id;
LIKE:
Case objCase = new Case();
objCase.Account_Name__c = 'Paypal';
// or add more code as per your requirement
insert objCase;
Now in Salesforce your Case is going to insert, so you need to write a trigger on Case object before insert event.
Hope it will help :)
Have a nice day!!