Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

Saturday, May 16, 2020

servicenow integration with salesforce

What is ServiceNow?

ServiceNow is a business service management platform that offers you IT support services, whether you are an IT business or handling the IT services. For reducing the work effort, getting work done with ease, enhancing resolution speed and minimizing cost, 

ServiceNow and Salesforce integration benefits

ServiceNow and Salesforce both are the major CRM systems, ServiceNow integration with Salesforce offers any business to run smoothly. It eases the work by providing access to multiple apps and synchronizing the data faster. Here are some benefits 

A step-by-step guide to integrate ServiceNow with Salesforce

Let’s start with Obtaining a Personal Developer Instance
1.      Log in to the ServiceNow developer site.
2.      Open the ‘Manage’ menu and click the ‘Instance’ menu item.
3.      Click the ‘Request Instance’ button.
  1. Select a ServiceNow version for the instance.
  2. When the instance is assigned, the screen updates to display the instance URL and the admin credentials. Copy the admin password to the clipboard. 
6. Click on the URL as shown in the attachment above it redirects to the login page use the Username and Password shown in the attachment above.
Here is the Apex Callout Code for the Case Insertion on the ServiceNow from the Salesforce.
 The trigger for the Case insertion:
trigger ServiceNow on Case (after insert) {
 for(Case c : Trigger.New){
 nameofyourcalloutclass.servicenowPost(c.CaseNumber); }
 } 
Above is the trigger which fires when the new Case is generated from the Salesforce organization. Class is called from the trigger which contains the whole functionality. 
Apex Class for the Callout.
public class InsertCase{
@future(callout = true)
public static void servicenowPost(String incidentCase){
Http http = new Http();
 HttpRequest req = new HttpRequest();
 HttpResponse res = new HttpResponse();
String username = ‘admin’;
String password = ‘$Test12345’;
Blob headerValue = Blob.valueOf (username + ‘:’ + password);
String authorizationHeader = ‘BASIC ‘+ EncodingUtil.base64Encode(headerValue); req.setHeader(‘Authorization’, authorizationHeader); req.setEndpoint(‘https://dev1111.service-now.com/api/now/v1/table/incident);
 req.setMethod(‘POST’); req.setHeader(‘Content-Type’, ‘application/json’); JSONGenerator gen = JSON.createGenerator(true); gen.writeStartObject();
//you can add as many mappings as you want gen.writeStringField (‘servicenowField’, incidentCase);
gen.writeEndObject();
 //you can now use String pretty as your body
String pretty = gen.getAsString();
 req.setBody(pretty);
 HttpResponse res = http.send(req); system.debug(res.getBody());
 }
} 
After creating Trigger and class, create a Case in your Salesforce organization and login to the ServiceNow instance. Search the Incident in the search menu and open the incident. Find the incident with the same case number on the ServiceNow instance.
Now the ServiceNow and Salesforce integration completed successfully, the features and functionalities of both the CRM systems can be used from one system.

Sunday, April 26, 2020

Difference between api, track and wire in Lightning Web Component



Below are the decorators used In LWC:-

@api

To expose a public property, decorate it with @api.

Public properties define the API for a component. An owner component that uses the component in its markup can access the component’s public properties. Public properties are reactive. If the value of reactive property changes, the component’s template rerenders any content that references the property.

To expose a public method, decorate it with @api. Public methods are part of a component’s API. You can use a JavaScript method to communicate down the containment hierarchy. For example, an owner calls a method on a child component that it contains.

@track

To track a private property’s value and re-render a component when it changes, decorate the property with @track. Tracked properties are also called private reactive properties.

@wire

To read Salesforce data, Lightning web components use a reactive wire service. When the wire service provisions data, the component rerenders. Components use @wire in their JavaScript class to specify a wire adaptor or an Apex method.