Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. interested_prop = String.escapeSingleQuotes(interested_prop);
  2. String qry = 'select ' + sObjectUtility.sObjectFields('srex__Matches__c') +' Id from Matches__c';
  3. string whereString = ' where Interested_in_Dealing__c = false';
  4. whereString += ' AND ('+ sObjName + ' =: propid ';
  5. whereString += ' OR '+ lookup2 +' =: propid )';
  6. whereString += ' AND ('+ sObjName + ' =: interested_prop ';
  7. whereString += ' OR '+ lookup2 +' =: interested_prop )';
  8.  
  9.  
  10. list<Matches__c> matches = Database.query(String.escapeSingleQuotes(qry)+String.escapeSingleQuotes(whereString));
  11.  
  12. if(matches.size() > 0){
  13. matches[0].Interested_in_Dealing__c = true;
  14. try{
  15. update matches;
  16. }catch(Exception ex){
  17. system.debug('Error occurred while perfoming DML Operation :::::'+ ex.getMessage());
  18. }
  19. }else{
  20. Matches__c new_match = new Matches__c();
  21. new_match.put(sObjName, prop_id);
  22. new_match.put(lookup2 , interested_prop);
  23. new_match.Interested_in_Dealing__c = true;
  24. try{
  25. List<Matches__c> matchlst = new List<Matches__c>();
  26. matchlst.add(new_match);
  27. insert matchlst;
  28. }catch(Exception ex){
  29. system.debug('Error occurred while perfoming DML Operation :::::'+ ex.getMessage());
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement