• Alfia Quadri 11
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 0
    Replies
Presently use the "username-password" oauth flow with salesforce (was the only viable option back in the day if I recall): https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_username_password_flow.htm&type=5
However it does not support refresh tokens.Also now available is a "server-to-server" flow: https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_client_credentials_flow.htm&type=5
That seems to be recommended over username-password however it also does not support refresh tokens.So I guess the question is: If we set the "Refresh Token Policy" in the console to "Valid until revoked" but we use a flow that doesn't support refresh tokens, will the access token itself stay valid until revoked?
If so, then we can just implement one shared salesforce auth per executor and assuming it stays authed indefinitely we'll just re-auth each time the framework restarts 
In opportunities object, I have a custom parent opportunity field.
I created a button using url hacking called Renew. On clicking the button It is not populating the parent opportunity field.
/lightning/o/Opportunity/new?defaultFieldValues=AccountId={!Opportunity.AccountId},Product_Type__c={!Opportunity.Product_Type__c},CF00N5600000LtmFR={!Opportunity.Name},CF00N5600000LtmFR_lkid={!Opportunity.Id}

I tried different ways

/lightning/o/Opportunity/new?defaultFieldValues=AccountId={!Opportunity.AccountId},Product_Type__c={!Opportunity.Product_Type__c},{!Opportunity.Parent_OpportunityId__c}={!Opportunity.Id}


 

I have a 2 formula date field, I want to add days and subtract days

contract_date = 12/31/2022
new_date = contract_date+1      (formula filed, adding 1 day)
it is returning 1/20/0001

contract_date = 12/18/2022
new_date = contract_date-14   (formula filed, subtracting 14 day)

its returning 7/20/2012

 

 

Hello, 
I was using url hacking, created a button, all my fields are populating when the button is clicked to create a new opportunity except the custom look up field.


/lightning/o/Opportunity/new?recordTypeId=01256000003H18t&defaultFieldValues=AccountId={!Opportunity.AccountId},Parent_OpportunityId__c={!Opportunity.Parent_OpportunityId__c}

the parent opportunity field is not populating, please advice
I am new, I need to create this as a json request body for apex call out.
{
 "query":  {
    "operator": "AND",
    "value": [
      {
        "field": "custom_attributes.social_network",
        "operator": "=",
        "value": "facebook"
      }, 
      {
        "field": "custom_attributes.social_network",
        "operator": "=",
        "value": "twitter"
      },
      {
        "field": "custom_attributes.social_network",
        "operator": "=",
        "value": "instagram"
      }

I have this so far
 
Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.intercom.io/contacts/search/');
        req.setMethod('POST');
        req.setHeader('Authorization', authorizationHeader);  
        req.setHeader('Accept', 'application/json');
        
        String jsonBody =  ?????? /// how to include the above
       
        req.setBody(jsonBody);

 
I used LinkedIn's Sales Navigator Search to get a list of leads/contacts. Is there a way to
  1. Export this list?
  2. An automatic bulk update to Salesforce?
I know there is a Sync CRM button but for that we need to go to every contact manually and update to the CRM
For example if I have a list of 50 contacts, is there a way, we can automate or easily have the contact list dumped into SF??
I am new to apex I am making an api call from salesforce to get contacts from another application. I am receiving contacts but in pages, I need to parse the response and make a call again to get the next page, What am I doing wrong that I get APEX CPU Execution time limit exceeded
The response I get in my first call is a list of contacts and
pages": {
        "type": "pages",
        "next": {
            "page": 42,
            "starting_after": "WzE2NjQ0MjUzM"
        },
        "page": 41,
        "per_page": 150,
        "total_pages": 56
    }

I need to send it this way in the request to query the next page
 
{
 "query":  {
    "field": "last_seen_at",
    "operator": ">",
    "value": "1646149510"
  },
  "pagination": {
    "per_page": 5,
    "starting_after": "1HaSB+xrOyyMXAkS"
  } 
}
Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://api.intercom.io/contacts/search/');
    req.setMethod('POST');
    String authorizationHeader = 'Bearer ' + 'dG9rOjM5N=';
    req.setHeader('Authorization', authorizationHeader);  
    req.setHeader('Accept', 'application/json');
    req.setHeader('Content-Type', 'application/json');
    req.setHeader('Intercom-Version', '2.6');
    Map<String, Object> m1 = new Map<String, Object> 
                { 
                    'value' => '1646149510',
                    'operator' => '>', 
                    'field' => 'last_seen_at'
                        };
                           

    
    String jsonBody = JSON.serialize(
    new Map<String, Object> {'query'=>m1}
    );
   
    req.setBody(jsonBody);
   
        HttpResponse res = h.send(req);
        Map<String, Object> results = (Map<String,Object>)JSON.deserializeUntyped(res.getBody());
        List<Object> listObject = (List<Object>)results.get('data');
        Map<String, Object>  pagesObject,NextpagesObject;
        pagesObject  = (Map<String, Object>)(results.get('pages'));
        NextpagesObject = (Map<String, Object>)(pagesObject.get('next'));
        while(NextpagesObject!=null)
        {
          Integer page = Integer.valueOf(NextpagesObject.get('page'));
          String starting_after=String.valueOf(NextpagesObject.get('starting_after'));
        
          Http h2 = new Http();
          HttpRequest req2 = new HttpRequest();
          req2.setEndpoint('https://api.intercom.io/contacts/search/');
          req2.setMethod('POST');
          String authorizationHeader2 = 'Bearer ' + 'dG9rOjM5N';
          req2.setHeader('Authorization', authorizationHeader2);  
          req2.setHeader('Accept', 'application/json');
          req2.setHeader('Content-Type', 'application/json');
          req2.setHeader('Intercom-Version', '2.6');
          
          Map<String, Object> m2 = new Map<String, Object> 
                { 
                    'value' => '1646149510',
                    'operator' => '>', 
                    'field' => 'last_seen_at'
                        };


                           
          Map<String, Object> m3 = new Map<String, Object> 
                {
                   'per_page'=> page,
                   'starting_after'=> starting_after
                } ;
                           
    
             String jsonBody2 = JSON.serialize(
                   new Map<String, Object> {'query'=>m2,
                              'pagination'=>m3}
                 );

   
         req2.setBody(jsonBody2);
         HttpResponse res2 = h.send(req2);
         Map<String, Object> results2 = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
         listObject = (List<Object>)(results2.get('data'));
         pagesObject  = (Map<String, Object>)(results2.get('pages'));
         NextpagesObject = (Map<String, Object>)(pagesObject.get('next'));
        
    }


 

I am new to apex, I am writing an apex class and I have the salesforce id, how do I update the contact record if I have the salesforce id.

Thanks
here is my apex class
I am getting this error

DEBUG|{"status":400,"error":"There was a problem in the JSON you submitted [5132df156cbaf320d27f8e06f3b61656]: logged with error code"}

PLEASE TELL ME HOW TO INCLUDE THE JSON???

public class makeCallOutIC1 {
    public String getContent(String url){
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.intercom.io/contacts/search/');
        req.setMethod('POST');
        String authorizationHeader = 'Bearer ' + 'd2222=';
        req.setHeader('Authorization', authorizationHeader);  
        req.setHeader('Accept', 'application/json');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Intercom-Version', '2.6');
        String body = '{'+
                       '"query": {' +
              '            "field": "last_seen_at", ' +
              '            "operator": ">", ' +
              '              "value": "1646149510",   ' +
              '        }' +
            '      }';
        

        req.setBody(body);
        HttpResponse res = h.send(req);
        return res.getBody();
        
    }
}
I am trying to connect to Intercom from Salesforce using External services.

https://developers.intercom.com/intercom-api-reference/reference/search-for-contacts

This is what the specification says. And I have the token and tried this on Postman and it works fine

$ curl https://api.intercom.io/contacts \ -X POST \
-H 'Authorization:Bearer <Your access token>' \
-H 'Accept:application/json'
-H 'Content-Type: application/json' -d

Now in External service I provided the JSON (see below).
Now where do I provide the auth code? I need to create a flow, use this external service and update a field from the values I get in response.

Please help me.

{
  "openapi": "3.0.1",
  "info": {
    "title": "SerachContactIntercom",
    "description": "Serach Intercom Active Contacts",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api.intercom.io"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/contacts/search/": {
      "post": {
        "description": "Auto generated using Swagger Inspector",
        "parameters": [
          {
            "name": "Intercom-Version",
            "in": "header",
            "required": false,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            },
            "example": "2.6"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/contacts_search_body"
              },
              "examples": {
                "0": {
                  "value": "{\n\"query\":  {\n    \"field\": \"last_seen_at\",\n    \"operator\": \">\",\n    \"value\": \"1646149510\"\n  }\n}"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Auto generated using Swagger Inspector"
          }
        },
        "servers": [
          {
            "url": "https://api.intercom.io"
          }
        ]
      },
      "servers": [
        {
          "url": "https://api.intercom.io"
        }
      ]
    }
  },
  "components": {
    "schemas": {
      "contactssearch_query": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "operator": {
            "type": "string"
          }
        }
      },
      "contacts_search_body": {
        "type": "object",
        "properties": {
          "query": {
            "$ref": "#/components/schemas/contactssearch_query"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}

 

I am new to apex, I am writing an apex class and I have the salesforce id, how do I update the contact record if I have the salesforce id.

Thanks