• palerra test 5
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
For following setup audit trail REST query

SELECT Action,CreatedById,CreatedBy.Username,CreatedDate,DelegateUser,Display,Id,Section FROM SetupAuditTrail

CreatedBy field is received as NULL for the actions performed by installed apps.
We receive CreatedById, however there seems no API  which would help us to map this to 'Automated Process'.

We get Username as "Automated Process" in setup audit trail UI.

Is there any way we can CreatedBy in case of actions performed by installes apps through setup audit trail REST API?
Hello,
We are calling salesforce REST API for object history from java.
Following are the sample queries, getting fired for different standard as well as custom objects

e.g.
1. SELECT Id, IsDeleted, Parent.Name, CreatedBy.Name, CreatedBy.Email, CreatedDate, Field, OldValue, NewValue FROM customObject4__History WHERE  CreatedDate > 2016-04-24T18:08:49Z order by CreatedDate

2. SELECT Id, IsDeleted, Parent.Name, Parent.LastModifiedBy.Name, Parent.LastModifiedBy.Email, Parent.LastModifiedDate, Field, OldValue, NewValue FROM customObject4__History where Parent.LastModifiedDate > 2016-04-24T18:09:09Z and Field = 'created' and IsDeleted = true order by Parent.LastModifiedDate

The response we receive is as below. This seems for query on large data sets.

 REST API return status of 400 with response: [{"message":"Your query request was running for too long.","errorCode":"QUERY_TIMEOUT"}]., status: 400]

From the analysis it seems that if the query is taking more than 2 minutes to run, salesforce server gives QUERY_TIMEOUT error.

1. Is there any way QUERY timeout can be increased? Can salesforce do it?
2. Query optimization is another way. Any pointers on how can above query be optmized? I understand the fields used in filter (where clause) should have an index for better performance (CreatedDate is by default indexed). What about other fields Parent.LastModifiedDate, Fields and IsDeleted ?
3. Does order by clause hampers performance?
4. Would batch size option help?

Any pointers on above queries would help.

Thanks,
Lalita



 
If there is any event related to "Login-As" access then it is seen in SetupAudit Trail however if I query using the REST API, it fails to return this event. What could be missing in the query due to which I don't see this?

Steps followed to see the logged activity:
1.For the Salseforce Admin User followed this path:
Administer-> Security Controls ->View Setup Audit Trail
There its showing all the Logged in using Login-As access for testUserName
in View Setup Audit Trail UI Page

2.When I fired the restAPI Query on workbench
Then I received only Logged out using Login-As access for testUserName.

In rest Explorer i tried
1)
/services/data/v36.0/query?q=SELECT+Action,CreatedById,CreatedBy.Username,CreatedDate,DelegateUser,Display,Id,Section+FROM+SetupAuditTrail+WHERE+CreatedDate+>+2016-07-17T17:45:27Z+ORDER+BY+CreatedDate+ASC+NULLS+FIRST

2)in SOQL
SELECT Action,CreatedById,CreatedDate,DelegateUser,Display FROM SetupAuditTrail ORDER BY CreatedDate DESC NULLS FIRST

If i can view it directly using the View SetupAuditTrail, why is it not returned as part of the REST/SOQL query?

Any help would be appreciated.

Thanks
For following setup audit trail REST query

SELECT Action,CreatedById,CreatedBy.Username,CreatedDate,DelegateUser,Display,Id,Section FROM SetupAuditTrail

CreatedBy field is received as NULL for the actions performed by installed apps.
We receive CreatedById, however there seems no API  which would help us to map this to 'Automated Process'.

We get Username as "Automated Process" in setup audit trail UI.

Is there any way we can CreatedBy in case of actions performed by installes apps through setup audit trail REST API?