Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interested_prop = String.escapeSingleQuotes(interested_prop);
- String qry = 'select ' + sObjectUtility.sObjectFields('srex__Matches__c') +' Id from Matches__c';
- string whereString = ' where Interested_in_Dealing__c = false';
- whereString += ' AND ('+ sObjName + ' =: propid ';
- whereString += ' OR '+ lookup2 +' =: propid )';
- whereString += ' AND ('+ sObjName + ' =: interested_prop ';
- whereString += ' OR '+ lookup2 +' =: interested_prop )';
- list<Matches__c> matches = Database.query(String.escapeSingleQuotes(qry)+String.escapeSingleQuotes(whereString));
- if(matches.size() > 0){
- matches[0].Interested_in_Dealing__c = true;
- try{
- update matches;
- }catch(Exception ex){
- system.debug('Error occurred while perfoming DML Operation :::::'+ ex.getMessage());
- }
- }else{
- Matches__c new_match = new Matches__c();
- new_match.put(sObjName, prop_id);
- new_match.put(lookup2 , interested_prop);
- new_match.Interested_in_Dealing__c = true;
- try{
- List<Matches__c> matchlst = new List<Matches__c>();
- matchlst.add(new_match);
- insert matchlst;
- }catch(Exception ex){
- system.debug('Error occurred while perfoming DML Operation :::::'+ ex.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement