Guest User

Untitled

a guest
Jul 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @RestResource(urlMapping='/QueryRecords/*')
  2. global with sharing class QueryRecords{
  3. @HttpPost
  4. global static void updateRecords(){
  5. String mobile = RestContext.request.getParameters().get('Mobile');
  6.  
  7. List<Contact> contactList = new List<Contact>();
  8. List<Lead> leadList = new List<Lead>();
  9. List<Task> taskList = new List<Task>();
  10.  
  11. contactList = [SELECT Id, Name FROM Contact WHERE MobilePhone =: mobile];
  12. leadList = [SELECT Id, Name FROM Lead WHERE MobilePhone =: mobile];
  13.  
  14. for(Contact obj : contactList){
  15. Task objTask = new Task();
  16. objTask.whoId = obj.Id;
  17. objTask.Description = mobile;
  18. taskList.add(objTask);
  19. }
  20. if(taskList.size() > 0){
  21. insert taskList;
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment