Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Content imported from a Scroll Translations translation file.
Sv translation
languageen

Implementation

To create a new Apex class, access Setup in SalesForce, and type in "Apex" in the quick search box. 

Select "Build ... Develop ... Apex Classes".

Create a new class. Add the following code:

Translations Ignore


Code Block
languagejava
titleSample Apex onClickToDial
@RestResource(urlMapping='/jtelACD/onClickToDial')
global with sharing class JTELACD_OnClickToDial{
    @HttpGet
    global static void doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;

        // This is how to access URLParams if required
        // List<String> URLParams = req.requestURI.split('/');
        // Example: ["","jtelACD","onClickToDial"]

        // Extract the request parameters
        String SalesForceID = req.params.get('SalesForceID');
        String CallerID = req.params.get('CallerID');
        String AgentUID = req.params.get('AgentUID');
        
        // Do some interesting logic to determine the service number
        String serviceNumber = 
'4980012345678'
CallerID;
        String serviceName   = '';
        
        res.addHeader( 'Content-Type', 'application/json' );
        res.responseBody = Blob.valueOf( '{ "ServiceNumber" : "' + serviceNumber + '", "ServiceName" : "' + serviceName + '" }' );
    }
}



CURL Test

First of all, obtain an OAUTH Token, see Testing with CURL.

The following CURL command can be used to test this API:

Translations Ignore


Code Block
titleCURL - onClickToDial Test
curl.exe --silent -i -X GET --header "Authorization: Bearer <OAUTH_TOKEN>" --header "Connection: Close" "https://<SALES_FORCE_INSTANCE_URL>/services/apexrest/jtelACD/onClickToDial?SalesForceID=<SalesForceRecordID>&CallerID=49894614950701&AgentUID=admin"




Sv translation
languagede

Status
colourRed
titleThis page is only available in English

Sv translation
languagefr

Mise en œuvre

Pour créer une nouvelle classe Apex, accédez à Setup dans SalesForce, et tapez "Apex" dans la boîte de recherche rapide. 

Sélectionnez "Construire ... Développer

Implementation

To create a new Apex class, access Setup in SalesForce, and type in "Apex" in the quick search box. 

Select "Build ... Develop

... Apex Classes".

Image Modified

Create a new class. Add the following code:

Créez une nouvelle classe. Ajoutez le code suivant :

Sample Apex
Translations Ignore


Code Block
languagejava
title
Exemple apex onClickToDial
@RestResource(urlMapping='/jtelACD/onClickToDial')
 global with sharing class JTELACD_OnClickToDial{
 
@HttpGet
 
global static void doGet() {
 
RestRequest req = RestContext.request;
 
RestResponse res = RestContext.response;
 
// This is how to access URLParams if required
 
// List<String> URLParams = req.requestURI.split('/');
 
// Example: ["","jtelACD","onClickToDial"]
 
// Extract the request parameters
 
String SalesForceID = req.params.get('SalesForceID');
 String CallerID = req.params.get('CallerID');
 
String AgentUID = req.params.get('AgentUID');
 
// Do some interesting logic to determine the service number
 
String serviceNumber = 
'4980012345678'
CallerID;
 
String serviceName 
= '';
 
res.addHeader( 'Content-Type', 'application/json' );
 
res.responseBody = Blob.valueOf( '{ "ServiceNumber" : "' + serviceNumber + '", "ServiceName" : "' + serviceName + '" }' );
 
} 
}
}



Test CURL

TestFirst of all, obtain an OAUTH Token, see 

Tout d'abord, obtenez un jeton OAUTH, voir Testing with CURL.

The following CURL command can be used to test this

La commande CURL suivante peut être utilisée pour tester cette API:

Test
Translations Ignore


Code Block
titleCURL - Test onClickToDial
curl.exe --silent -i -X GET --header "Authorization: Bearer <OAUTH_TOKEN>" --header "Connection: Close" "https://<SALES_FORCE_INSTANCE_URL>/services/apexrest/jtelACD/onClickToDial?SalesForceID=<SalesForceRecordID>&CallerID=49894614950701&AgentUID=admin"