• Joseph A
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
I'm trying to migrate to REST API and according to SFMC documentation in order to update of an asset using PATCH I should use https://my_sub_domain.rest.marketingcloudapis.com/asset/v1/content/assets/{id}. However, all requests end with 
 
string(747) "HTTP/1.1 404 Not Found x-mashery-message-id: 8c94a90d-ba59-4c88-9dd8-0e8be18f2b8c x-mashery-responder: 07-rt06 strict-transport-security: max-age=15552000; preload Content-Security-Policy: upgrade-insecure-requests x-xss-protection: 1; mode=block x-frame-options: DENY x-content-type-options: nosniff cache-control: no-cache, must-revalidate, max-age=0, no-store, private Referrer-Policy: strict-origin-when-cross-origin Vary: Origin, X-HTTP-Method-Override Content-Type: application/json; charset=utf-8 Content-Length: 147 Date: Mon, 04 May 2020 21:53:38 GMT Connection: keep-alive {"documentation":"https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm","errorcode":404,"message":"Not Found"}"
My code:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer ' . $token ));
        curl_setopt($ch, CURLOPT_HEADER, 1);    
        curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($ch);


What do I miss?
Hi, I'm trying to access ContentNote with REST API and each query results in zero records althrought there are at least 600k records. Selecting data from other objects works fine. Any ideas?
Hi'
Number of fields in my Account object needs to be verified against a remote API prior to be updated. Now, due to how SF triggers / classes / HttpResponse limitations I ended with logging errors into a custom object which contains message, user id and a display flag (true/false). The idea is to retreive messages by user id, display in an alert window and mark as displayed.
Now I'm cosidering running a scheduled task every a few seconds to retreive and display notifications. Number of issues I'm facing right now:
1. Is it possible to display a custom popup on SF lighting or some kind of notification from scheduled Apex class?
2. Is there any other more sufficient way to display alerts (sending emails is not really an option here)? 

Hi,
I need to run some verifications in trigger "before update" against a remote API and perform future actions based on its response . I found that Apex class function cannot return any response due to synchronous / asynchronous issues between triggers and HttpResponse. Is there any way to go around?

We're having an issue here. Here is my code. Everything works fine "after update" but the portion portion where it involves daysBetween calculation is not working "after insert" (API). 
 
trigger LeadReAssigment on Opportunity (after insert, after update) {
    
    // reference to static class to prevent from trigger firing once
        
                
        List<Opportunity> ops= [SELECT Id, StageName, OwnerId, Date_Begun__c, AccountId FROM Opportunity WHERE Id = :Trigger.New[0].Id];
        //list<Opportunity> ops= trigger.new;
        
        integer DaysOld = 0;
        
        for(Opportunity o: ops) {
        
            string OriginalOwnerId = o.OwnerId;
            
            Date StartDate =  System.Today();
            Date EndDate = o.Date_Begun__c;
            DaysOld = EndDate.daysBetween(StartDate);
            
            System.debug('Days Diff:'+DaysOld);
            
            //System.debug(o.StageName+' Records:'+ops.size()+' OWNER ID'+o.OwnerId+' Id: '+ o.Id);
            if(o.StageName == 'Funded'){
                o.OwnerId = 'bbb';
            }else if(o.StageName == 'Rejected'){
                o.OwnerId = 'ccc';
            }else if(o.StageName == 'Closed'){
                o.OwnerId = 'yyy';
            }else if(o.StageName == 'Pending' && DaysOld > 60){
                o.OwnerId = 'xxx';
            }else if(o.StageName == 'Opened' && DaysOld > 60){
                o.OwnerId = 'vvv';
            }
			System.debug('AccountId: '+o.AccountId+' Original Owner'+OriginalOwnerId+' New Owner:'+o.OwnerId);
            if(OriginalOwnerId != o.OwnerId){
                //update Account and Contact
				List<Account> acc= [SELECT Id FROM Account WHERE Id = :o.AccountId];
				for(Account o3: acc) {
					o3.OwnerId = o.OwnerId;
				}
				if(acc.size() > 0){
					update acc;
				}
				List<Contact> cont= [SELECT Id FROM Contact WHERE AccountId = :o.AccountId];
				for(Contact o4: cont) {
					o4.OwnerId = o.OwnerId;
				}
				if(cont.size() > 0){
					update cont;
				}
            }
        }
        
        if(counter > 0){
            System.debug('UPDATE DONE');
            update ops;
        }
    //}
}



 
Hi, I'm trying to access ContentNote with REST API and each query results in zero records althrought there are at least 600k records. Selecting data from other objects works fine. Any ideas?

Hi,
I need to run some verifications in trigger "before update" against a remote API and perform future actions based on its response . I found that Apex class function cannot return any response due to synchronous / asynchronous issues between triggers and HttpResponse. Is there any way to go around?

We're having an issue here. Here is my code. Everything works fine "after update" but the portion portion where it involves daysBetween calculation is not working "after insert" (API). 
 
trigger LeadReAssigment on Opportunity (after insert, after update) {
    
    // reference to static class to prevent from trigger firing once
        
                
        List<Opportunity> ops= [SELECT Id, StageName, OwnerId, Date_Begun__c, AccountId FROM Opportunity WHERE Id = :Trigger.New[0].Id];
        //list<Opportunity> ops= trigger.new;
        
        integer DaysOld = 0;
        
        for(Opportunity o: ops) {
        
            string OriginalOwnerId = o.OwnerId;
            
            Date StartDate =  System.Today();
            Date EndDate = o.Date_Begun__c;
            DaysOld = EndDate.daysBetween(StartDate);
            
            System.debug('Days Diff:'+DaysOld);
            
            //System.debug(o.StageName+' Records:'+ops.size()+' OWNER ID'+o.OwnerId+' Id: '+ o.Id);
            if(o.StageName == 'Funded'){
                o.OwnerId = 'bbb';
            }else if(o.StageName == 'Rejected'){
                o.OwnerId = 'ccc';
            }else if(o.StageName == 'Closed'){
                o.OwnerId = 'yyy';
            }else if(o.StageName == 'Pending' && DaysOld > 60){
                o.OwnerId = 'xxx';
            }else if(o.StageName == 'Opened' && DaysOld > 60){
                o.OwnerId = 'vvv';
            }
			System.debug('AccountId: '+o.AccountId+' Original Owner'+OriginalOwnerId+' New Owner:'+o.OwnerId);
            if(OriginalOwnerId != o.OwnerId){
                //update Account and Contact
				List<Account> acc= [SELECT Id FROM Account WHERE Id = :o.AccountId];
				for(Account o3: acc) {
					o3.OwnerId = o.OwnerId;
				}
				if(acc.size() > 0){
					update acc;
				}
				List<Contact> cont= [SELECT Id FROM Contact WHERE AccountId = :o.AccountId];
				for(Contact o4: cont) {
					o4.OwnerId = o.OwnerId;
				}
				if(cont.size() > 0){
					update cont;
				}
            }
        }
        
        if(counter > 0){
            System.debug('UPDATE DONE');
            update ops;
        }
    //}
}