• Daniel Peaper 8
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies

I came across some code recently and I was surprised that no parameters were included in the call to the helper class method. Instead the helper class method just used all of the trigger methods directly. So you end up with code like this:-

if(Trigger.isBefore && Trigger.isInsert) {

AccountTriggerHelper.beforeInsert();

}

Then in the helper class:-

public with sharing class AccountTriggerHelper {

public static void beforeInsert() {

System.Debug('Trigger new is: ' + Trigger.new);

}
}

And this works perfectly but I can't find any reference to coding like this in the documentation or on Trailhead.

 

Hi Everyone,

I'm struggling with a callout that I'm trying send using a named credential and a REST query. The problem is that I keep getting a runtime error due to the > symbol. However, the >= works fine when I test it from postman. Here is a portion of my code:-

modifiedDate = '/products?where=modifieddate>=\'' + modifiedDate + '\'';
System.debug(modifiedDate);
//Poll Cin7 for changes
//Define the transaction variables.
HttpRequest req = New HttpRequest();
HttpResponse res = New HttpResponse();
Http h = New Http();
//Configure the request
req.setEndpoint('callout:Cin7' + modifiedDate);
req.setMethod('GET');
req.setTimeout(120000);
//Configure standard headers
req.setHeader('Accept', '*/*');
req.setHeader('Content-Type', 'application/json');

//Attempt the callout - Log an error on exception.
res = h.send(req);

The error that I receive is: System.CalloutException: Illegal character in opaque part at index 40: callout:Cin7/products?where=modifieddate>='2022-04-08T10:01:58.000Z'

Any ideas how to solve this?

Hi All, I'm looking for some advice on best practice. I want to loop through Options and I've come up with the following solution which actually works. What I want to know is whether or not my method of a loop within a loop is best practice or if there is a better way?

String json = '{'+
    '  \"TrackingCategories\": ['+
    '    {'+
    '      \"Name\": \"Region\",'+
    '      \"Status\": \"ACTIVE\",'+
    '      \"TrackingCategoryID\": \"351953c4-8127-4009-88c3-f9cd8c9cbe9f\",'+
    '      \"Options\": ['+
    '        {'+
    '          \"TrackingOptionID\": \"ce205173-7387-4651-9726-2cf4c5405ba2\",'+
    '          \"Name\": \"Eastside\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"6eb12fdf-63de-4033-98df-be679d84e3c2\",'+
    '          \"Name\": \"North\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"6159bdd4-b634-4338-a664-e929aa73f70f\",'+
    '          \"Name\": \"South\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"161ad543-97ab-4436-8213-e0d794b1ea90\",'+
    '          \"Name\": \"West Coast\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        }'+
    '      ]'+
    '    }'+
    '  ]'+
    '}';
TrackingOptionsResponse obj = TrackingOptionsResponse.parse(json);
System.debug('obj='+obj);



for(TrackingOptionsResponse.TrackingCategories r :obj.TrackingCategories){
    system.debug('r='+r.Name);
    System.debug('r2='+r.Options);
    for(TrackingOptionsResponse.Options l :r.options){
        System.debug('l='+l.Name);
    }
}

Thanks,

Dan

I have created a scratch org and I wish to setup Facebook Messenger as a channel in Omni Channel. However, when I try to add a new channel I get the error message "You don't have any Messaging permission set licenses."

I enabled the following features in my definition file:

"features": ["ServiceCloud", "ServiceUser", "LightningServiceConsole", "LiveAgent", "Chatbot","LiveMessage"]

The doco (https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm#so_liveagent) says that it enables messaging for Facebook Messenger.

Am I missing some settings or is there another issue?

I have inherited the following code in a vfp controller class with a hard coded url. I decided to modify it:-

String customDomainName = 'https://toptechservice—partial-c.documentforce.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=';

Integer index = DistributionPublicUrl.IndexOf('/a/',0);

String strSubString = DistributionPublicUrl.substring(index);

customDomainName = customDomainName + ContentVersionId + '&operationContext=DELIVERY&contentId=' + ContentDocumentId + '&page=0&d=';

customDomainName = customDomainName + strSubString + '&oid=' + orgId + '&dpt=null&viewId=';

system.debug('customDomainName: '+customDomainName);
       
I decided to modify it using URL.getSalesforceBaseUrl() as follows:

String orgDomain = URL.getSalesforceBaseUrl().getHost();

String orgURL = orgDomain.replace('visual','document');

String customDomainName = 'https://'+orgURL+'/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=';


Depite both versions appearing identical in the Debug log only the hard-coded version works. When I view the vfp in the browser I can see that the string passed by my modified code has it's domain address changed to the Site URL. The string passed by the hard-coded version is not changed and hence works.

I just want to understand.

Hi Everyone,

I'm struggling with a callout that I'm trying send using a named credential and a REST query. The problem is that I keep getting a runtime error due to the > symbol. However, the >= works fine when I test it from postman. Here is a portion of my code:-

modifiedDate = '/products?where=modifieddate>=\'' + modifiedDate + '\'';
System.debug(modifiedDate);
//Poll Cin7 for changes
//Define the transaction variables.
HttpRequest req = New HttpRequest();
HttpResponse res = New HttpResponse();
Http h = New Http();
//Configure the request
req.setEndpoint('callout:Cin7' + modifiedDate);
req.setMethod('GET');
req.setTimeout(120000);
//Configure standard headers
req.setHeader('Accept', '*/*');
req.setHeader('Content-Type', 'application/json');

//Attempt the callout - Log an error on exception.
res = h.send(req);

The error that I receive is: System.CalloutException: Illegal character in opaque part at index 40: callout:Cin7/products?where=modifieddate>='2022-04-08T10:01:58.000Z'

Any ideas how to solve this?

Hi All, I'm looking for some advice on best practice. I want to loop through Options and I've come up with the following solution which actually works. What I want to know is whether or not my method of a loop within a loop is best practice or if there is a better way?

String json = '{'+
    '  \"TrackingCategories\": ['+
    '    {'+
    '      \"Name\": \"Region\",'+
    '      \"Status\": \"ACTIVE\",'+
    '      \"TrackingCategoryID\": \"351953c4-8127-4009-88c3-f9cd8c9cbe9f\",'+
    '      \"Options\": ['+
    '        {'+
    '          \"TrackingOptionID\": \"ce205173-7387-4651-9726-2cf4c5405ba2\",'+
    '          \"Name\": \"Eastside\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"6eb12fdf-63de-4033-98df-be679d84e3c2\",'+
    '          \"Name\": \"North\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"6159bdd4-b634-4338-a664-e929aa73f70f\",'+
    '          \"Name\": \"South\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        },'+
    '        {'+
    '          \"TrackingOptionID\": \"161ad543-97ab-4436-8213-e0d794b1ea90\",'+
    '          \"Name\": \"West Coast\",'+
    '          \"Status\": \"ACTIVE\"'+
    '        }'+
    '      ]'+
    '    }'+
    '  ]'+
    '}';
TrackingOptionsResponse obj = TrackingOptionsResponse.parse(json);
System.debug('obj='+obj);



for(TrackingOptionsResponse.TrackingCategories r :obj.TrackingCategories){
    system.debug('r='+r.Name);
    System.debug('r2='+r.Options);
    for(TrackingOptionsResponse.Options l :r.options){
        System.debug('l='+l.Name);
    }
}

Thanks,

Dan

I have created a scratch org and I wish to setup Facebook Messenger as a channel in Omni Channel. However, when I try to add a new channel I get the error message "You don't have any Messaging permission set licenses."

I enabled the following features in my definition file:

"features": ["ServiceCloud", "ServiceUser", "LightningServiceConsole", "LiveAgent", "Chatbot","LiveMessage"]

The doco (https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm#so_liveagent) says that it enables messaging for Facebook Messenger.

Am I missing some settings or is there another issue?