• Mads Peter Rommedahl
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hey, I currently have an Apex function which takes a name and an existing Contact, and if the current Contact name is our dummy name 'Dyreven' but the new name is NOT it updates the Contact name. Like this:
 
// Small method to check if the passed name variable is NOT 'Dyreven' but the current name is. Then replace 'Dyreven' with the new name

    private static Contact checkForUpdatedName(String name, Contact con){
        if (name != 'Dyreven') {
            if (con.LastName == 'Dyreven') {
                con.LastName = name;
                update con;
            }
        }
        return con;
    }

 
However, instead of having the dummy name hardcoded in the Apex I want my Apex to pull a list of dummy names from custom metadata and then check through all of them. So it should be possible to have a custom list of dummy names and then the Apex code would check against that list instead of against a hardcoded String like above.

How can I do this? Are lists supported as a custom metadata type?
Hey all, I'm making a callback Apex class that's supposed to act differently depending on whether it gets a GET call or a POST call to a specific endpoint. The callback class has two exposed methods, doGet() and doPost() annotated with @HttpGet and @HttpPost respectively like this:

@RestResource(urlMapping='/inMobileCallback') global with sharing class InMobileCallback {
@HttpGet
global static void doGet() {
// Logic
}
@HttpPost
global static void doPost(){
// logic
}

But when I try to make a POST request to the designated REST endpoint using Postman (https://www.getpostman.com/), I get a 500 response (with or without a body):
User-added image


and from looking in my custom Apex Errors Report I can see that this is due to it trying to run the doGet() (which, naturally, fails due to there being none of the expected GET parameters):
User-added image

So, basically, what is happening is that despite explicitly sending a POST request, Salesforce runs the doGet() instead of doPost(). Since doGet() is the first method in the class, my guess is that either it's somehow just ignoring the annotations altogether or it misinterprets the POST request from Postman as a GET request... regardless, I'm thoroughly confused by this. Have anyone seen anything like this?
Hi all,
I'm trying to code an integration between two web services - an online text messaging gateway and a Salesforce installation. So far, I've managed to get Salesforce callouts to work (meaning you can send text messages from Salesforce at the click of a button), but I'm struggling with the other way around: The text messaging gateway supports making a GET callback to a URL of my choice with the status of the text message sent (Delivered/Failed) - but even though I've made a Salesforce API endpoint to handle the callback and update the respective records in Salesforce, the callbacks keep failing with 401 Unauthorized and the INVALID_SESSION_ID error code.

I know this problem is related to OAuth 2 and if this was me making the callback, I would make sure to make a prior call to /oauth2/token, use the access token and all that jazz, but I'm not able to do that - all I can do is specify which URL the gateway should make a GET call to (with the text message-specific parameters added to the URL).

Thus, what I really need is some way to either perma-authorize any GET calls coming from their domain or bypass the OAuth 2 workflow altogether. I have looked around everywhere but haven't been able to find any useful information that doesn't involve first calling /oauth2/token and THEN calling the API endpoint, which, as mentioned, is not an option.

Any ideas?
Hey, I currently have an Apex function which takes a name and an existing Contact, and if the current Contact name is our dummy name 'Dyreven' but the new name is NOT it updates the Contact name. Like this:
 
// Small method to check if the passed name variable is NOT 'Dyreven' but the current name is. Then replace 'Dyreven' with the new name

    private static Contact checkForUpdatedName(String name, Contact con){
        if (name != 'Dyreven') {
            if (con.LastName == 'Dyreven') {
                con.LastName = name;
                update con;
            }
        }
        return con;
    }

 
However, instead of having the dummy name hardcoded in the Apex I want my Apex to pull a list of dummy names from custom metadata and then check through all of them. So it should be possible to have a custom list of dummy names and then the Apex code would check against that list instead of against a hardcoded String like above.

How can I do this? Are lists supported as a custom metadata type?
Hi all,
I'm trying to code an integration between two web services - an online text messaging gateway and a Salesforce installation. So far, I've managed to get Salesforce callouts to work (meaning you can send text messages from Salesforce at the click of a button), but I'm struggling with the other way around: The text messaging gateway supports making a GET callback to a URL of my choice with the status of the text message sent (Delivered/Failed) - but even though I've made a Salesforce API endpoint to handle the callback and update the respective records in Salesforce, the callbacks keep failing with 401 Unauthorized and the INVALID_SESSION_ID error code.

I know this problem is related to OAuth 2 and if this was me making the callback, I would make sure to make a prior call to /oauth2/token, use the access token and all that jazz, but I'm not able to do that - all I can do is specify which URL the gateway should make a GET call to (with the text message-specific parameters added to the URL).

Thus, what I really need is some way to either perma-authorize any GET calls coming from their domain or bypass the OAuth 2 workflow altogether. I have looked around everywhere but haven't been able to find any useful information that doesn't involve first calling /oauth2/token and THEN calling the API endpoint, which, as mentioned, is not an option.

Any ideas?