• Rutger Gernandt
  • NEWBIE
  • 10 Points
  • Member since 2018
  • De Warme Winkel

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Deal all,

I have created an integration with an external service (Google) and am using named credentials in this use-case (with a principal user). There is  strange renewal behavior however, that seems quite reproducible:
- if I try to connect after X time (let's say an hour since this is the token window with Google), the first attempt will give an 401 Unauthorized error. 
- if I retry everything works fine 
- looking at the logs, at the named credential it states: Retry on 401 is true
- however, there is no automatic retry on 401, given that a manual second try does make it work...
- this seems to suggest that SF approach to tokens is to not renewal tokens continuesly, but to get one when needed.
- not an illogical concept given the multitenant nature and that some integrations maybe seldom used. However why does this not work then? I also cannot find any documentation on the renewal process exact nature and/or this setting. 
- I am using a Google Auth. Provider over the general one btw (if that has any influence in the backend at all beside preconfig).

Context: this is especially problematic since as a workaround I am now performing a 'dummy' GET request from the service. However that means it limits my max amount of calls to 50 instead of 100. While in theory (but very seldomly) I could get over 100 anyway and I should probably resort to a batch and/or queable apex approach, however this is so rare that it is not in the 80% range of the current implementation. Under normal circumstances I can however get around 50-70 batched calls, and because of the unexpected overhead of the dummy call this is now suddenly a problem... 

There also seems no possibily to check the token renewal date against the current date fow example? But maybe it is not even saved if my theory about the implementation is correct. The only thing I can think of atm is creating an oAuth flow myself and store it in a custom setting, but that would be quite a dissapointing workaround... There is also no possibilty to place the dml outside of the context of the call it seems to me? 

Any help is appreciated! Thanks in advance! 
Dear all,

I am mimicing the behavior of the Event object when entering time and dates in a Custom object (because I cannot use the Event object for this use-case). To be able to show these events well in the Salesforce agenda, show them in a proper format in some tables, but also to integrate with external services I have combined the seperate date and time fields (start time + date & end time + date) in a formula date/time field.

While I have a formula for the start date & time that works well, however my formula for the end date & time is just 162 characters too long when compiling... The workaround via processbuilder is not an option, since time field are (not yet) available... 

Does anybody has a suggestion to shorter the check for the daylight saving time? As a guide to the formula's variables: Datum = Start Date, Einddatum = End Date, Tijd = Time, Eindtijd = End Time.

The functionality is: 
- if no end date & no start time is available, use start date as end date and time in such a way that it is displayed as a day length activitity in SF. 
- if no end date is available, but there is an end time: use the start date and the end time. 
- if an end date is available, but there is no end time (day length activity), use enddate and add time
- if an end date and end time is available, use these

The formula: 
IF(ISNULL(Einddatum__c),

  IF(ISNULL(Tijd__c),
 
  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((24-2)/24),  
  DATETIMEVALUE(Datum__c) + ((24-1)/24)),

  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-2)/24) + (MINUTE(Tijd__c)/1440), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-1)/24) + (MINUTE(Tijd__c)/1440))),

  IF(ISNULL(Eindtijd__c),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) - (2/24),  
  DATETIMEVALUE(Einddatum__c) - (1/24)),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-2)/24) + (MINUTE(Eindtijd__c)/1440), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-1)/24) + (MINUTE(Eindtijd__c)/1440)))

)

Any help is higly appreciated! 

 
There is an issue with my HTTP request.salesforce is not allowing me to use PATCH method.
Below are the notification which i get after calling a patch.

System.CalloutException: Invalid HTTP method: PATCH.

when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
Dear all,

I am mimicing the behavior of the Event object when entering time and dates in a Custom object (because I cannot use the Event object for this use-case). To be able to show these events well in the Salesforce agenda, show them in a proper format in some tables, but also to integrate with external services I have combined the seperate date and time fields (start time + date & end time + date) in a formula date/time field.

While I have a formula for the start date & time that works well, however my formula for the end date & time is just 162 characters too long when compiling... The workaround via processbuilder is not an option, since time field are (not yet) available... 

Does anybody has a suggestion to shorter the check for the daylight saving time? As a guide to the formula's variables: Datum = Start Date, Einddatum = End Date, Tijd = Time, Eindtijd = End Time.

The functionality is: 
- if no end date & no start time is available, use start date as end date and time in such a way that it is displayed as a day length activitity in SF. 
- if no end date is available, but there is an end time: use the start date and the end time. 
- if an end date is available, but there is no end time (day length activity), use enddate and add time
- if an end date and end time is available, use these

The formula: 
IF(ISNULL(Einddatum__c),

  IF(ISNULL(Tijd__c),
 
  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((24-2)/24),  
  DATETIMEVALUE(Datum__c) + ((24-1)/24)),

  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-2)/24) + (MINUTE(Tijd__c)/1440), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-1)/24) + (MINUTE(Tijd__c)/1440))),

  IF(ISNULL(Eindtijd__c),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) - (2/24),  
  DATETIMEVALUE(Einddatum__c) - (1/24)),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-2)/24) + (MINUTE(Eindtijd__c)/1440), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-1)/24) + (MINUTE(Eindtijd__c)/1440)))

)

Any help is higly appreciated!