Guest User

Untitled

a guest
Oct 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. [ select Layout.Name from ProfileLayout where ProfileId = :UserInfo.getProfileId() AND RecordTypeId = :record.RecordTypeId ]
  2.  
  3. static String restGet(String endPoint, String method, String sid) {
  4. Http h = new Http();
  5. HttpRequest hr = new HttpRequest();
  6. hr.setHeader('Authorization', 'Bearer ' + sid);
  7. hr.setTimeout(60000);
  8. hr.setEndpoint(endPoint);
  9. hr.setMethod(method);
  10. HttpResponse r = h.send(hr);
  11. return r.getBody();
  12. }
  13. static String toolingAPISOQL( String query) {
  14. String baseURL = URL.getSalesforceBaseUrl().toExternalForm();
  15. return restGet( baseURL +
  16. '/services/data/v41.0/tooling/query?q='+ (query.replace(' ', '+'))
  17. ,
  18. 'GET', UserInfo.getSessionId() );
  19. }
  20.  
  21. static String getLayoutNameForCurrentUserProfile( Id recordId ) {
  22. String body = toolingAPISOQL('select Layout.Name from ProfileLayout where ProfileId = '' + UserInfo.getProfileId() + '' AND RecordTypeId = '' + [ select RecordTypeId from Account where id = :recordId].RecordTypeId + ''');
  23. System.debug(LoggingLevel.ERROR, '@@@ v: ' + body );
  24. String name = body.substringBetween('"Name":"', '"');
  25. System.debug(LoggingLevel.ERROR, '@@@ v: ' + name );
  26. return name;
  27. }
  28. getLayoutNameForCurrentUserProfile('001g000001hLEAj');
Add Comment
Please, Sign In to add comment