0

Java Code: I have coded the following using REST API to connect to Salesforce. Following code is from the URL to get Schema or fields of AccountTeamMember (standard) object after establishing connection with salesforce org through RESTAPI:

String schemaUrl = instanceurl + "/services/data/v54.0/sobjects/AccountTeamMember/describe";
log.info("schemeaUrl " + schemaUrl);
String responseString = "emptyschema";

Header printHeader = new BasicHeader("X-PrettyPrint", "1");
                
Header oAuthHeader = new BasicHeader("Authorization", "OAuth " + accesstoken);
                
HttpGet schemaHttpGet = new HttpGet(schemaUrl);
                
schemaHttpGet.addHeader(oAuthHeader);
                
schemaHttpGet.addHeader(printHeader);
             
int count = 0;

response = httpClient.execute(schemaHttpGet);
log.info("after executing HTTPGet : " + response);
int iStatusCode = response.getStatusLine().getStatusCode();
log.info("iStatusCode : " + iStatusCode);
if (iStatusCode == 200) {
          
    HttpEntity httpEntity = response.getEntity();
    log.warn("httpEntity : " + httpEntity);
    if (httpEntity != null) {

        log.info("before responseString " + responseString);
        responseString = EntityUtils.toString(httpEntity);
        log.info("after responseString " + responseString);

Here after running this code, I got all fields of AccountTeamMember (a standard object associated to the Account object) in Json format, if I keep AccountTeams enable, through RestAPI I am able to get all fields as json object and if disable then 404 status code.

So here is my question: Is there any other way to know AccountTeams is enabled for Account object other than this 404 status code and manually login to Salesforce org?

1 Answer 1

1

You can use Metadata API to get this information. In AccountSettings there is a field enableAccountTeams which Indicates whether account teams are enabled (true) or not (false).

You can refer the Metadata API Developer Guide which provides information on how to use Java Code to access Metadata API.

You can get this info using SOQL through Tooling API. Refer to the Tooling API Developer Guide for more details.

Select id, IsAccountTeamsEnabled From AccountSettings
5
  • Thank you so much for your reply! Could you please tell me how can i get accountsettings fields from soql I worte this query in developer console Select id,name, (Select fields(all) From AccountSettings limit 10) From Account
    – Akhil Umap
    Commented Jun 2, 2022 at 7:59
  • @AkhilUmap - Please find my updated answer.
    – Saroj Bera
    Commented Jun 2, 2022 at 15:08
  • Thank you once again for your help! I am new to salesforce would you please suggest me how to learn salesforce from scratch and master it with all APIS
    – Akhil Umap
    Commented Jun 5, 2022 at 9:04
  • @AkhilUmap - Salesforce Trailhead is a good start for you. Please create an account and start learning.
    – Saroj Bera
    Commented Jun 6, 2022 at 6:35
  • Thank you so much!!
    – Akhil Umap
    Commented Jun 9, 2022 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .