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
Ramesh GudepuRamesh Gudepu 

(Need Help) Error : unable to disable custom application from System admin profile using API call

public class CustomApp {
MetadataConnection metadataconnection;
ConnectorConfig metaConfig;

private void disableCustomApp(String endpoint, String metaUserName, String metaPassword) throws Exception {
  getMetaConnection( endpoint, metaUserName, metaPassword);
  Profile profile = new Profile();
     profile.setFullName("Admin");
     ProfileApplicationVisibility appVisibility =new ProfileApplicationVisibility();
        appVisibility.setApplication("Sales Automation");
        appVisibility.setVisible(true);
        profile.setApplicationVisibilities(new ProfileApplicationVisibility[] {appVisibility});
  AsyncResult[] asyncResults = this.metadataconnection.create(new Metadata[] {profile});
  if (asyncResults == null) {
    System.out.println("The custom app was not disabled successfully");
   return;
  }
  do {
   printAsyncResultStatus(asyncResults);
   Thread.sleep(2000);
   asyncResults = this.metadataconnection.checkStatus(new String[] {asyncResults[0].getId()});
  }
  while (!asyncResults[0].isDone());
  if(asyncResults[0].getState().equals("completed")){
   System.out.println("The custom app was disabled successfully");
  }
  printAsyncResultStatus(asyncResults);
}

private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
  if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
   throw new Exception("The object status cannot be retrieved");
  }
  AsyncResult asyncResult = asyncResults[0];
  if (asyncResult.getStatusCode() != null) {
  }
  System.out.println("Object with id:" + asyncResult.getId() + " is " + asyncResult.getState());
  System.out.println("Object with id:" + asyncResult.getId() + " is " + asyncResult.getMessage());
}

public void getMetaConnection(String endpoint, String metaUserName, String metaPassword){
  try {
      metaConfig = new ConnectorConfig();
   metaConfig.setServiceEndpoint(endpoint);
   metaConfig.setManualLogin(true);
   LoginResult loginResult = new EnterpriseConnection(metaConfig).login(metaUserName, metaPassword);
   metaConfig.setServiceEndpoint(loginResult.getMetadataServerUrl());
   metaConfig.setSessionId(loginResult.getSessionId());
   metadataconnection = new MetadataConnection(metaConfig);
  } catch (ConnectionException ce) {
   throw new RuntimeException("INVALID_LOGIN", ce);
  }
}

Error :
Object with id:04si0000000xDFWAA2 is InProgress
Object with id:04si0000000xDFWAA2 is null
Object with id:04si0000000xDFWAA2 is Error
Object with id:04si0000000xDFWAA2 is duplicate value found: <unknown> duplicates value on record with id: <unknown>
    
Ashish_SFDCAshish_SFDC
Hi Ramesh, 


Need more information on this, What exactly are you tring to achieve here. 

Paste the exact error and also enable debug logs and paste the response so that we can look for clues. 


Regards,
Ashish
Ramesh GudepuRamesh Gudepu
Dear Ashish,

i am tring to disable custom application from Admin profile using API.so here you can find debug log
Debug Log:

WSC: Creating a new connection to https://login.salesforce.com/services/Soap/c/27.0 Proxy = DIRECT username null
------------ Request start   ----------
<?xml version="1.0" encoding="UTF-8"?><env:Envelope
   xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
  <m:login xmlns:m="urn:enterprise.soap.sforce.com" xmlns:sobj="urn:sobject.enterprise.soap.sforce.com">
   <m:username>rabit.test@techsophy.com</m:username>
   <m:password>sophy@345ldFRnCwRnXTRTY7L0voocDVl</m:password>
  </m:login>
</env:Body>
</env:Envelope>
------------ Request end   ----------
null=[HTTP/1.1 200 OK]
Date=[Tue, 15 Apr 2014 12:37:20 GMT]
Content-Length=[789]
Content-Encoding=[gzip]
Content-Type=[text/xml;charset=UTF-8]
------------ Response start ----------
  <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
        <loginResponse>
          <result>
            <metadataServerUrl>https://na15.salesforce.com/services/Soap/m/27.0/00Di0000000jozA</metadataServerUrl>
            <passwordExpired>false</passwordExpired>
            <sandbox>false</sandbox>
            <serverUrl>https://na15.salesforce.com/services/Soap/c/27.0/00Di0000000jozA</serverUrl>
            <sessionId>00Di0000000jozA!AQQAQFhHU6ldAKvQRiy5vh_niAnUNHVUNhwuEkDu8ddlcyLuT0_tH5NK.fz7cre9x0_sfQRiJADBZSmZXh_ejgFKWNj3PTtT</sessionId>
            <userId>005i0000002oh4EAAQ</userId>
            <userInfo>
              <accessibilityMode>false</accessibilityMode>
              <currencySymbol>$</currencySymbol>
              <orgAttachmentFileSizeLimit>5242880</orgAttachmentFileSizeLimit>
              <orgDefaultCurrencyIsoCode>USD</orgDefaultCurrencyIsoCode>
              <orgDisallowHtmlAttachments>false</orgDisallowHtmlAttachments>
              <orgHasPersonAccounts>false</orgHasPersonAccounts>
              <organizationId>00Di0000000jozAEAQ</organizationId>
              <organizationMultiCurrency>false</organizationMultiCurrency>
              <organizationName>undefined</organizationName>
              <profileId>00ei0000001EDuoAAG</profileId>
              <roleId xsi:nil="true"/>
                <sessionSecondsValid>7200</sessionSecondsValid>
                <userDefaultCurrencyIsoCode xsi:nil="true"/>
                  <userEmail>ramesh.g@techsophy.com</userEmail>
                  <userFullName>Kenneth Allen</userFullName>
                  <userId>005i0000002oh4EAAQ</userId>
                  <userLanguage>en_US</userLanguage>
                  <userLocale>en_US</userLocale>
                  <userName>rabit.test@techsophy.com</userName>
                  <userTimeZone>America/Los_Angeles</userTimeZone>
                  <userType>Standard</userType>
                  <userUiSkin>Theme3</userUiSkin>
              </userInfo>
            </result>
          </loginResponse>
        </soapenv:Body>
      </soapenv:Envelope>
------------ Response end   ----------
WSC: Creating a new connection to https://na15.salesforce.com/services/Soap/m/27.0/00Di0000000jozA Proxy = DIRECT username null
------------ Request start   ----------
<?xml version="1.0" encoding="UTF-8"?><env:Envelope
   xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
  <SessionHeader xmlns="http://soap.sforce.com/2006/04/metadata">
   <sessionId>00Di0000000jozA!AQQAQFhHU6ldAKvQRiy5vh_niAnUNHVUNhwuEkDu8ddlcyLuT0_tH5NK.fz7cre9x0_sfQRiJADBZSmZXh_ejgFKWNj3PTtT</sessionId>
  </SessionHeader>
</env:Header>
<env:Body>
  <m:create xmlns:m="http://soap.sforce.com/2006/04/metadata" xmlns:sobj="null">
   <m:metadata xsi:type="m:Profile">
    <m:fullName>Admin</m:fullName>
    <m:applicationVisibilities>
     <m:application>Sales Automation</m:application>
     <m:default>false</m:default>
     <m:visible>true</m:visible>
    </m:applicationVisibilities>
   </m:metadata>
  </m:create>
</env:Body>
</env:Envelope>
------------ Request end   ----------
null=[HTTP/1.1 200 OK]
Date=[Tue, 15 Apr 2014 12:37:21 GMT]
Content-Length=[223]
Content-Encoding=[gzip]
Content-Type=[text/xml;charset=UTF-8]
------------ Response start ----------
  <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/2006/04/metadata">
      <soapenv:Body>
        <createResponse>
          <result>
            <done>false</done>
            <id>04si0000000xHeaAAE</id>
            <state>InProgress</state>
        </result>
      </createResponse>
    </soapenv:Body>
  </soapenv:Envelope>
------------ Response end   ----------
WSC: Creating a new connection to https://na15.salesforce.com/services/Soap/m/27.0/00Di0000000jozA Proxy = DIRECT username null
------------ Request start   ----------
<?xml version="1.0" encoding="UTF-8"?><env:Envelope
   xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
  <SessionHeader xmlns="http://soap.sforce.com/2006/04/metadata">
   <sessionId>00Di0000000jozA!AQQAQFhHU6ldAKvQRiy5vh_niAnUNHVUNhwuEkDu8ddlcyLuT0_tH5NK.fz7cre9x0_sfQRiJADBZSmZXh_ejgFKWNj3PTtT</sessionId>
  </SessionHeader>
</env:Header>
<env:Body>
  <m:checkStatus xmlns:m="http://soap.sforce.com/2006/04/metadata" xmlns:sobj="null">
   <m:asyncProcessId>04si0000000xHeaAAE</m:asyncProcessId>
  </m:checkStatus>
</env:Body>
</env:Envelope>
------------ Request end   ----------
null=[HTTP/1.1 200 OK]
Date=[Tue, 15 Apr 2014 12:37:24 GMT]
Content-Length=[305]
Content-Encoding=[gzip]
Content-Type=[text/xml;charset=UTF-8]
------------ Response start ----------
  <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/2006/04/metadata">
      <soapenv:Body>
        <checkStatusResponse>
          <result>
            <done>true</done>
            <id>04si0000000xHeaAAE</id>
            <message>duplicate value found: &lt;unknown&gt; duplicates value on record with id: &lt;unknown&gt;</message>
            <state>Error</state>
            <statusCode>DUPLICATE_VALUE</statusCode>
        </result>
      </checkStatusResponse>
    </soapenv:Body>
  </soapenv:Envelope>
------------ Response end   ----------

but unable to disabling custom application from Admin profile due to this error :

Object with id:04si0000000xHeaAAE is InProgress
Object with id:04si0000000xHeaAAE is null
Object with id:04si0000000xHeaAAE is Error
Object with id:04si0000000xHeaAAE is duplicate value found: <unknown> duplicates value on record with id: <unknown>

is there any other approache to achive this ......

Thanks in advance.......
Ashish_SFDCAshish_SFDC
Hi Ramesh, 


Are you trying to Disable Custom App that is enabled to a System Admin Profile? I tried doing it in the UI that worked Is that the one you are trying to Disable using API?

What comes up when you open this object ? https://login.salesforce.com/04si0000000xHeaAAE


There is a Known issue here : https://success.salesforce.com/issues_view?id=a1p30000000T2URAA0 

Is this related to same issue?


This seems to be the validation on the User Object but you should call the Custom Apps on the API and not the User Object. 

See the below links with similar errors, can help. 


https://developer.salesforce.com/forums/ForumsMain?id=906F00000009A2vIAE

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009A3jIAE

https://developer.salesforce.com/forums/ForumsMain?id=906F000000099fKIAQ

http://salesforce.stackexchange.com/questions/6063/object-deploy-fails-with-duplicate-value-found-unknown-duplicates-value-on


Regards,
Ashish