• Neha Patil 20
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
Hello Experts,

I want someone to put some light to teh new feature introduced by salesforce Named credential

My scenario is somethign like this:
1.I have a rest based webservice in target org which i am invoking through source org
2.I have created named credential in source org as shown below
User-added image
3. Further in my code that invokes the webservice i have written the below satatements:
HttpRequest req= new HttpRequest();

String reqBody='{"vEmail":"'+email+'",'+'"vSubject":"'+subject+'",'+'"vDate":"'+dt+'"}';
		req.setEndpoint('callout:ExternalPortalCreds');
		req.setMethod('POST');
		req.setBody(reqBody);
		Http http=new Http();
		HttpResponse res= http.send(req);

However this gives error as Session expired or invalid session id. How do i get the session id if i want to use named credential in my code?
Any help would be appreciated

Regards
Neha
Hello Experts,

I am using a simple tag 
<force:inputField value="{!v.task.Priority}" />
to display the priority picklist field. The field does get displayed but the values are not displayed correcty as shown in the screenshot below:
User-added image
Can anyone pls help how can i fix this distortion? Any help would be appreciated

Thanks
 
Hello Experts,

I want someone to put some light to teh new feature introduced by salesforce Named credential

My scenario is somethign like this:
1.I have a rest based webservice in target org which i am invoking through source org
2.I have created named credential in source org as shown below
User-added image
3. Further in my code that invokes the webservice i have written the below satatements:
HttpRequest req= new HttpRequest();

String reqBody='{"vEmail":"'+email+'",'+'"vSubject":"'+subject+'",'+'"vDate":"'+dt+'"}';
		req.setEndpoint('callout:ExternalPortalCreds');
		req.setMethod('POST');
		req.setBody(reqBody);
		Http http=new Http();
		HttpResponse res= http.send(req);

However this gives error as Session expired or invalid session id. How do i get the session id if i want to use named credential in my code?
Any help would be appreciated

Regards
Neha
Hi,

      i have developed a apex class for connecting with the third party but now i'm going to write a batch job on that anyone guide me to developa batch job.i have look into some examples but completely not understood.

this is my class :


global with sharing class Service {
    
    global static void getIncident(String subject){  
        
        Http http = new Http();
        HttpRequest req =  new HttpRequest();
        HttpResponse res = new HttpResponse();
         
        string text = subject;
            
        req.setEndpoint('https://dev24994.service-now.com/api/now/table/incident?sysparm_fields=impact%2Cincident_state%2Csys_updated_onONLast%2520minute%40javascript%3Ags.minutesAgoStart(30)%40javascript%3Ags.minutesAgoEnd(0)%2Cshort_description%2Csys_id%2Ccontact_type&u_sftype=true&sysparm_limit=10');      
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json');
        
        String username = 'admin';
        String password = 'xxxxxx';
       
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'BASIC ' +
        EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
              
        res = http.send(req);
        System.debug('jsonrResult :' + res.getBody());
      
        Deserialization.ResponseResult result = (Deserialization.ResponseResult)JSON.deserialize(res.getBody(),     Deserialization.ResponseResult.class);
        System.debug('Results == :' + result );
        
        List<Case> casesToUpsert = new List<Case>();        
        for(Deserialization d : theresult.result ){
                            
                Case c = new Case();
                c.Priority = d.impact;
                c.Status = d.incident_state;
                c.Subject = d.short_description;
                c.ServiceNowId__c = d.sys_id;
                c.Origin = d.contact_type;
                
                casesToUpsert.add(c);
               
        }
        system.debug('Cases to UPsert ::: ' +casesToUpsert);
        
        if(casesToUpsert.size()>0){
            Database.upsert(casesToUpsert,false) ;
        }
             
    }
    
}

if it is possible develop batch job on that for better understanding

Thanks In Advance
Hello Experts,

I am using a simple tag 
<force:inputField value="{!v.task.Priority}" />
to display the priority picklist field. The field does get displayed but the values are not displayed correcty as shown in the screenshot below:
User-added image
Can anyone pls help how can i fix this distortion? Any help would be appreciated

Thanks