• Barton Ledford
  • NEWBIE
  • 5 Points
  • Member since 2014
  • Technical Architect
  • CodeScience, Inc


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
We can get updateMetadata to work with reports.


We cannot update an existing report via the metadata api.  upsertMetadata will insert a new report if we change any character of the report fullname, but won't do an update if the fullname remains the same (Error: duplicate values on record with id <unknown>).  If I try updateMetadata, I get "In field: fullName - no Report named NSPC__Client_App_Reports/Top_Goals_for_Top_Salespeople found".  Any help is much appreciated.

HTTP h = new HTTP();
HTTPRequest req = new HTTPRequest();
req.setMethod('POST');
req.setHeader('Content-Type', 'text/xml');
req.setHeader('SOAPAction', 'upsertMetadata');
String b = '<?xml version="1.0" encoding="UTF-8"?>';
b += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
b += '<soapenv:Header>';
b += '<ns1:SessionHeader soapenv:mustUnderstand="1" xmlns:ns1="http://soap.sforce.com/2006/04/metadata">';
b += '<ns1:sessionId>' + UserInfo.getSessionId() + '</ns1:sessionId>';
b += '</ns1:SessionHeader>';
b += '</soapenv:Header>';
b += '<soapenv:Body>';
b += '<upsertMetadata xmlns="http://soap.sforce.com/2006/04/metadata">';
b += '<metadata xsi:type="ns2:Report" xmlns:ns2="http://soap.sforce.com/2006/04/metadata">';
b += '<fullName>NSPC__Client_App_Reports/Top_Goals_for_Top_Salespeople</fullName>';
b += '<columns>';
b += '<field>CUST_ID</field>';
b += '</columns>';
b += '<filter>';
b += '<criteriaItems>';
b += '<column>NSPC__Event__c.NSPC__Name__c</column>';
b += '<operator>equals</operator>';
b += '<value>View</value>';
b += '</criteriaItems>';
b += '<criteriaItems>';
b += '<column>CUST_OWNER_NAME</column>';
b += '<operator>equals</operator>';
b += '<value>John Doe,Barton Ledford</value>';
b += '</criteriaItems>';
b += '</filter>';
b += '<format>Summary</format>';
b += '<groupingsDown>';
b += '<dateGranularity>Day</dateGranularity>';
b += '<field>NSPC__Event__c.NSPC__Name__c</field>';
b += '<sortOrder>Asc</sortOrder>';
b += '</groupingsDown>';
b += '<name>Top Goals for Top Salespeople</name>';
b += '<params>';
b += '<name>co</name>';
b += '<value>1</value>';
b += '</params>';
b += '<reportType>CustomEntity$NSPC__Event__c</reportType>';
b += '<scope>organization</scope>';
b += '<showDetails>false</showDetails>';
b += '<timeFrameFilter>';
b += '<dateColumn>NSPC__FolioEvent__c.NSPC__eventTime__c</dateColumn>';
b += '<interval>INTERVAL_CUSTOM</interval>';
b += '</timeFrameFilter>';
b += '</metadata>';
b += '</upsertMetadata>';
b += '</soapenv:Body>';
b += '</soapenv:Envelope>';
req.setBody(b);
req.setCompressed(false);
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/m/31.0');
HTTPResponse resp = h.send(req);
System.debug(resp.getBody());
 
Connected App Option " Limit access to apps that are currently installed and have "Admin approved users are pre-authorized" as their Permitted Users setting." is preventing OAuth from working with our App. It works when the flag is unchecked, doesn't when it is checked. Every profile in the org has access to the app and "Admin approved users are pre-authorized" is selected on the Connected App page.  This appears to be a Salesforce bug.  Has anyone else had this experience? 
Connected App Option " Limit access to apps that are currently installed and have "Admin approved users are pre-authorized" as their Permitted Users setting." is preventing OAuth from working with our App. It works when the flag is unchecked, doesn't when it is checked. Every profile in the org has access to the app and "Admin approved users are pre-authorized" is selected on the Connected App page.  This appears to be a Salesforce bug.  Has anyone else had this experience?