Rick Mann
Tera Expert

I wanted to put together a brief article around integrating ServiceNow with Dell's TechDirect warranty API to collect an asset's Warranty Expiration date. In this article, I will detail the Outbound REST message setup, scripting the business rules and UI action I used.  This will be some basic REST work, but I thought I would share.  Please feel free to comment if you see errors or improvements I can make.

Obtain your Dell API key from Dell TechDirect.  Once you are approved for a key, Dell will provide the key along with some code samples (see the attached PDF).  Currently I have a key only for their Warranty API.

Setting up the Outbound REST message and GET method:

  1. Create a new Outbound REST message with endpoint https://sandbox.api.dell.com/support/assetinfo/v4 (Dell will initially setup you up within their sandbox environment and then migrate your work to their prod endpoint)
  2. Add HTTP headers for Accept and Content-Type, both with a value of application/json
  3. Save the new record, which will create your default GET method.
  4. Obtaining the warranty end date requires endpoint:  https://sandbox.api.dell.com/support/assetinfo/v4/getassetwarranty/{id}?apikey={apikey}
  5. Setup your GET method for some test runs with the following attributes:
    • Endpoint:  https://sandbox.api.dell.com/support/assetinfo/v4/geassetwarranty/${id}
    • HTTP headers for Accept and Content-Type, both with a value of application/json
    • HTTP Query Parameter for apikey where the value is your key (We'll remove this parameter later and store the key as a property).
    • Variable substitutions for id with a value of a valid service tag

find_real_file.png

find_real_file.png

You want to grab the EndDate value from AssetEntitlementData[0] array.

find_real_file.png

Setting up a Business Rule to update Warranty Expiration

I decided to setup an On Before Insert and Update business rule to run when the Warranty Expiration field is empty and the Serial Number is not empty and the workstation is not a Mac. 

(function executeRule(current, previous /*null when async*/) {
	
	var st = current.serial_number;
	
	try {
		var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
		r.setStringParameterNoEscape('id', st);
		r.setQueryParameter('apikey', gs.getProperty('DellTechDirectKey'));
		r.setHttpTimeout(10000);
		r.setEccParameter('skip_sensor', true);
		var response = r.execute();
		var responseBody = response.getBody();
		var httpStatus = response.getStatusCode();
		gs.info("Status = " + httpStatus);
		gs.info("Response Body = " + responseBody);
		
		if (httpStatus == '200'){
			var responseObj = JSON.parse(responseBody);
			var edate = responseObj.AssetWarrantyResponse[0].AssetEntitlementData[0].EndDate.substring(0, 10);
			current.warranty_expiration = edate;
		}else{
			gs.addErrorMessage('Looks like we ran into a problem.  HTTP status: ' + httpStatus);
		}
	}
	catch(ex) {
		var message = ex.getMessage();
	}	
	
})(current, previous);

Setting up the UI Action to check warranty expiration:

I setup a Form Button UI action to only display if the Serial Number is not empty and the workstation is not a Mac.  This gives our Service Desk a method to validate the Warranty Expiration.

var st = current.serial_number;
var curdate = current.warranty_expiration;

try {
	var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
	r.setStringParameterNoEscape('service_tag', st);
	//r.setQueryParameter(gs.getProperty('DellTechDirectKey'));
	r.setQueryParameter('apikey', gs.getProperty('DellTechDirectKey'));
	r.setHttpTimeout(10000);
	r.setEccParameter('skip_sensor', true);
	var response = r.execute();
	var responseBody = response.getBody();
	var httpStatus = response.getStatusCode();
	gs.info("Status = " + httpStatus);
	gs.info("Response Body = " + responseBody);

	if(httpStatus == '200'){
		var responseObj = JSON.parse(responseBody);
		var edate = responseObj.AssetWarrantyResponse[0].AssetEntitlementData[0].EndDate.substring(0, 10);
		
		if(curdate == edate){
			gs.addInfoMessage('The Warranty Expiration date is correct');
			action.setRedirectURL(current);
			current.update();		

		}
		if(curdate != edate){
			gs.addInfoMessage('The Warranty Expiration date changed from ' + curdate + ' to ' + edate);	
			current.warranty_expiration = edate;	
			action.setRedirectURL(current);
			current.update();
		}
	}
		else{
			gs.addErrorMessage('Could not retrieve Warranty Expiration information: ' + httpStatus);
			action.setRedirectURL(current);
			current.update();
	}
}
catch(ex) {
	var message = ex.getMessage();
}

I hope this is helpful and please let me know if you have any feedback.

 

 

Comments
robertjaneway
Tera Contributor

Thanks for the guide. Quick question though. I see you mentioned where you are supposed to remove the api key as a parameter and use it as a property. 

I am probably just misunderstanding where to input that api key in the subsequent scripts for the button and business rule.

 

I also noticed that I don't an end_date from our query.  Our api shows a ship_date only. is that something that dell has possibly changed?

Rick Mann
Tera Expert

Hey Robert

You will need to add a "setQueryParameter" value when you call your REST method.  I used the line "r.setQueryParameter('apikey', gs.getProperty('DellTechDirectKey'));"  This will generate the URL in the format: https://api.dell.com/support/assetinfo/v4/getassetwarranty/?apikey= <valid API key>

 

More info on the setQueryParameter.

Are you able to see End Date under the AssetEntitlementData response?  I had to parse the response arrays to get the end date I wanted.

 

find_real_file.png

 

Let me know if this helps.  Thanks for checking out the post.

Rick

robertjaneway
Tera Contributor

Thanks. I am following the article to the letter if possible using our own api information.

 

From the rest message test. This is the response returned for me.

 

{"AssetHeaderResponse":[{"AssetHeaderData":{"BUID":"11","ServiceTag":"******","ShipDate":"2017-02-24T00:00:00","CountryLookupCode":"US","LocalChannel":"65","CustomerNumber":"","ItemClassCode":"J2002","IsDuplicate":false,"MachineDescription":"Precision Tower 5810","OrderNumber":"","ParentServiceTag":null,"CompanyNumber":""},"ProductHeaderData":{"SystemDescription":"Precision Tower 5810","ProductId":"precision-t5810-workstation","ProductFamily":"Desktops & All-in-Ones","LOB":"Dell Precision WorkStation","LOBFriendlyName":"Precision WorkStation"}}],"InvalidFormatAssets":{"BadAssets":[]},"InvalidBILAssets":{"BadAssets":[]},"ExcessTags":{"BadAssets":[]},"AdditionalInformation":null}

 

So it looks like our api is pulling a different response array.

 

The business rule and form ui button are where i am running into hiccups.

Rick Mann
Tera Expert

Can you post the endpoint you're using?  Be sure you're using the "Getassetwarranty" operation and not the "Getassetheader". 

Rick

robertjaneway
Tera Contributor

Thanks again. Not sure how I missed that.

Rick Mann
Tera Expert

Excellent.  Glad to help.

Katie A
Mega Guru

This is an excellent solution! Thanks for posting.

In case anyone is interested, I made a slightly modified version that runs daily in a Scheduled Job to set the Warranty Expiration date on all Dell computers. That way the date is added on all Dell computers without updating the record individually or clicking on a UI Action. The query gets all computers that have the string 'Dell' in the Model ID display name and do not have a Warranty Expiration date set already.

(function () {

  // Get Computer records
  var cmp = new GlideRecord('cmdb_ci_computer');
  // Model Name contains Dell
  cmp.addQuery('model_id.display_name', 'CONTAINS', 'Dell');
  // Warranty Expiration date not set already
  cmp.addNotNullQuery('warranty_expiration');
  cmp.setLimit(10000);
  cmp.query();
  while (cmp.next()) {
    // Get Serial Number
    var serial_number = cmp.serial_number.toString();

    // Check if Serial Number empty
    if (!serial_number) {
      gs.logError('ERROR: Unable to get Dell Warranty Expiration. Computer Serial Number is missing. Computer Name: ' + cmp.name, 'ITAM - Dell Warranty');
      // Continue to next iteration
      continue;
    }

    // Get Dell Tech Direct API Key
    var apikey = gs.getProperty('DellTechDirectKey').toString();
    var warranty_expiration;

    // Send REST API message to Dell TechDirect resource URL to get asset warranty information
    try {
      var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
      r.setStringParameterNoEscape('id', serial_number);
      r.setQueryParameter('apikey', apikey);
      r.setHttpTimeout(10000);
      r.setEccParameter('skip_sensor', true);
      var response = r.execute();
      var responseBody = response.getBody();
      var httpStatus = response.getStatusCode();

      // Check if status is 200
      if (httpStatus.toString() == '200') {
        var responseObj = JSON.parse(responseBody);
        // Parse Warranty Expiration date truncate timestamp to get date only
        warranty_expiration = responseObj.AssetWarrantyResponse[0].AssetEntitlementData[0].EndDate.substring(0, 10);
      // If status not 200 log error message and continue to next iteration
      } else {
        gs.logError('ERROR: Unable to get Dell Warranty Expiration. HTTP status: ' + httpStatus, 'ITAM - Dell Warranty');
        continue;
      }
    } catch (ex) {
      var message = ex.getMessage();
      gs.logError('ERROR: Unable to get Dell Warranty Expiration. ' + message, 'ITAM - Dell Warranty');
      continue;
    }

    // Set Warranty Expiration on Computer
    if (warranty_expiration) {
      cmp.warranty_expiration = warranty_expiration;
      cmp.update();
    }

  }

})();




jherrell
Giga Contributor

Hello. 

This guide has been amazing.  I am confused on one thing though.  Where are you storing the apikey as a property after you remove it from the "HTTP Query Parameters"?

Katie A
Mega Guru

Create a new 'string' property in System Properties.

In the script, the property is accessed with gs.getProperty(). Pass in the name of the property as a parameter. In my example below, the name of the custom property is 'DellTechDirectKey'. See my previous reply in this thread for the full code.

// Get Dell Tech Direct API Key
var apikey = gs.getProperty('DellTechDirectKey').toString();
Rick Mann
Tera Expert

I'm glad the article is helpful.  The apikey property is called in this line: 

 

r.setQueryParameter('apikey', gs.getProperty('DellTechDirectKey'));

You'll need to setup a new system property to store your key value.

find_real_file.png

Let me know if you have any questions.

jherrell
Giga Contributor

So I created this string and it is giving me an error 500.  Any ideas what may cause this?

 

Its giving this error when I try and Check Warranty.

 

Katie A
Mega Guru

Can you print out the full error message in the system log? Check to make sure you are using the correct URL in the outbound REST message and that you have authentication set up properly as well.

jherrell
Giga Contributor

So this is a bit interesting - It appears that the issue is that my serial numbers are set to all caps.  I changed a few to lower case and they started pulling in the warranty expiration.

jherrell
Giga Contributor

I have had a bit of time to test this and its working great.  I only have one issue and I am not sure how I need to accomplish it.  

 

I have about 24 of our machines that are showing a warranty expiration that is incorrect.  I reached out to Dell about this and they stated that the dates shown are for the "Digital Delivery Entitlement".  I need to add a line to my code to ignore this information so that our Warranty expirations aren't updated after warranty expiration with the DDE.  Any suggestions?

Rick Mann
Tera Expert

I think I see what you are referring to.  I have a JSON element for "Dell Digital Delivery".  I'm probably working on the assumption that my standard warranty end date is the first value in the AssetEntitementData array (responseObj.AssetWarrantyResponse[0].AssetEntitlementData[0].EndDate.substring(0, 10);)

 

find_real_file.png

jherrell
Giga Contributor

Yes, that is it.  I was going through and typing up a reply to this as you posted.  It is not happening on all of our machines, however, there are a few that are not showing the warranty as the first entry.  

For Example, I ran a test on a few of the assets in question.  See below.

"AssetEntitlementData":

{
"StartDate":"2022-11-30T00:00:00",
"EndDate":"2022-12-01T00:00:00",
"ServiceLevelDescription":"Dell",
"ServiceLevelCode":"DL","ServiceLevelGroup":11,
"EntitlementType":"INITIAL",
"ServiceProvider":"DELL",
"ItemNumber":"999-0036"},

 

{

"StartDate":"2014-11-28T00:00:00",
"EndDate":"2022-11-28T23:59:59",
"ServiceLevelDescription":"Dell Digitial Delivery",
"ServiceLevelCode":"D",
"ServiceLevelGroup":11,"EntitlementType":"INITIAL",
"ServiceProvider":"DELL",
"ItemNumber":"422-0052"},

{
"StartDate":"2014-11-28T00:00:00",
"EndDate":"2017-11-28T23:59:59",
"ServiceLevelDescription":"Complete Care / Accidental Damage",
"ServiceLevelCode":"CC",
"ServiceLevelGroup":11,
"EntitlementType":"INITIAL",
"ServiceProvider":"DELL",
"ItemNumber":"973-9184"},

 

{
"StartDate":"2015-11-29T00:00:00",
"EndDate":"2017-11-28T23:59:59",
"ServiceLevelDescription":"Onsite Service After Remote Diagnosis (Consumer Customer)/ Next Business Day Onsite After Remote Diagnosis (CommercialCustomer)",
"ServiceLevelCode":"ND",
"ServiceLevelGroup":5,
"EntitlementType":"EXTENDED",
"ServiceProvider":"UNY",
"ItemNumber":"995-0071"},

For this particular example the assets warranty is listed 4th.  I am not sure why some of these machines are showing this way.  Is there a workaround for this?  

Rick Mann
Tera Expert

I didn't account for the possibility that the desired EndDate might be in another array position.  I'll have to update the scripts running in my instance.  I'm working with our Asset Manager to confirm which "ServiceLevel" end date we want.

Here is a code snippet that should do what is needed.  The script is looping through the AssetEntitlementData array to find the value where "ServiceLevelDescription" contains "Onsite Service After Remote Diagnosis".  If it finds the text, then it will grab the end date for that array value.

 

var responseObj = JSON.parse(responseBody);
	var arrayl = responseObj.AssetWarrantyResponse[0].AssetEntitlementData.length;
	for(var i = 0; i < arrayl; i++){
		if(responseObj.AssetWarrantyResponse[0].AssetEntitlementData[i].ServiceLevelDescription.indexOf('Onsite Service After Remote Diagnosis')>-1){			
			var edate = responseObj.AssetWarrantyResponse[0].AssetEntitlementData[i].EndDate.substring(0, 10);
			gs.info(edate);
		}
	}
jonGriff
Tera Expert

Where is this value created?

jonGriff
Tera Expert

Thanks for the detailed information Rich Mann and Katie A!

Kai Tingey
Tera Guru

Hi There,

I'm trying to get this going at the moment, however looks like Dell has changed up how they return information.

I can get the response to the REST message no worries, i'm just having trouble extracting the data from it.

 

the end point is now https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements

 

and the response looks like:

 

[{"id":960576074,"serviceTag":"xxxx","orderBuid":1401,"shipDate":"2019-02-19T19:00:00Z","productCode":"PL003","localChannel":"PUB","productId":"precision-3630-workstation","productLineDescription":"PRECISION 3630","productFamily":"Unknown","systemDescription":"Precision 3630 Tower","productLobDescription":"Fixed Workstations","countryCode":"AU","duplicated":false,"invalid":false,"entitlements":[{"itemNumber":"W-000229372","startDate":"2019-02-19T19:00:00Z","endDate":"2020-02-21T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"POW","serviceLevelDescription":"Next Business Day 5x8 Onsite Support - Parts Only","serviceLevelGroup":null},{"itemNumber":"W-000229357","startDate":"2019-02-19T19:00:00Z","endDate":"2020-02-21T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"PHONESUPP","serviceLevelDescription":"Limited Technical Phone Support","serviceLevelGroup":null},{"itemNumber":"W-000229371","startDate":"2019-02-19T19:00:00Z","endDate":"2020-02-21T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"NBD","serviceLevelDescription":"Next Business Day Onsite Support","serviceLevelGroup":null},{"itemNumber":"W-000229437","startDate":"2019-02-19T19:00:00Z","endDate":"2022-02-21T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"PROSUPIT","serviceLevelDescription":"ProSupport Technical Support 7x24","serviceLevelGroup":null},{"itemNumber":"W-000229436","startDate":"2020-02-21T19:00:00Z","endDate":"2022-02-22T18:59:59.999Z","entitlementType":"EXTENDED","serviceLevelCode":"NBD","serviceLevelDescription":"Next Business Day Onsite Support","serviceLevelGroup":null}]}]

So what i need is to pull the end date of the entitlements array. But when i try to do it like this:

var edate = responseObj.entitlements.endDate;

i get 'undefined'

as you can see there are a couple of endDate entries, for each warranty type. so that's probably not helping much. What i probably want is the prosupport one.

how do i peel that end date of out there and into a variable?

Rick Mann
Tera Expert

Kai

Entitlements is an array and it looks like Pro Support is the 4th item in the array.  You may want to try something like this:

 

var edate = responseObj.entitlements[3].endDate;

 

Let me know if this helps.

Rick

Kai Tingey
Tera Guru

Hi Rick,

 

Thanks for the response.

When i try to set the variable in that way, it seems to stop processing the script.

 

at the moment i'm just doing all this in a fix script for testing, using gs.info to report back results.

if i change it to 

var edate = responseObj.entitlements[3].endDate;

it stops doing anything after that (and it doesn't matter what number i use in entitlements[x])

e.g.

var edate = responseObj.entitlements.endDate;

gs.info("edate: " + edate);

gives me "edate: undefined"

if i change it to 

var edate = responseObj.entitlements[3].endDate;

gs.info("edate: " + edate);

it doesn't do anything

Kai Tingey
Tera Guru

got it, it needed to be: var edate = responseObj[0].entitlements[3].endDate.substring(0, 10);

 

thanks for your help!

synthia
Giga Expert

Hi Katie,

I have a similar requirement to update the Warranty Expiration in alm_Asset table based on the display name and serial number .I have copied your script to the Scheduled Job and made changes accordingly. Should I also create the REST message "DellTechDirect" ? Can you please guide me through this ?

Thank you.

 

 

 

synthia
Giga Expert

I am getting the below error when I execute the scheduled job:

org.mozilla.javascript.EcmaError: Cannot convert null to an object.
Caused by error in <refname> at line 1

==> 1: (function () {
2:
3: // Get Computer records
4: var cmp = new GlideRecord('alm_asset');

skhan
Tera Contributor

Hello Rick,

 

Thank you for positing this helpful article. I am new with rest api setup. I got all the information that i need form Dell.

Now when i am trying to create the outbound rest message, the Endpoint field is using my user ID and its greyed out and doesn't let me edit.

Can you tell me how can I change this option.

 

Also, for Authentication. I should select OAuth 2.0 and create OAuth profile right? If yes then should I select "Connect to third party OAuth Provider"?

Also when i try to create it, the Client ID field is using my user id and it is greyed out. Can you tell me how to fix this as well.

 

I have both Web_service_admin and OAuth_admin role.

 


Thank you so much!

Sami

Rick Mann
Tera Expert

Could you post a screen shot of what you're seeing on the REST method setup?  As for authentication, you will need to pass the API key in as a query parameter.

Hope this helps.

John Schmalhors
Kilo Contributor

@Kai Tingey do you have any guidance on how to authenticate with v5? It's mandatory to include Bearer Authorization in the header now. 

Kai Tingey
Tera Guru

Hi John


Thanks for bringing that to my attention, I hadn't realized it had changed (noone had complained that our UI action for the warranty check was no longer working).

I'll have a look into it and I'll post back if I come up with a fix.

John Schmalhors
Kilo Contributor

I figured out the OAuth2.0 profile/Authorization issue but i need a script to renew the token for the Business rule... Also, I've been working on a Fixed Script to update the existing computers without "Warranty Expiration Date" but I think I'm too novice. So if you come up with something, I'd be very appreciative! 

John Schmalhors
Kilo Contributor

I cant figure out how to get the endDate where the  serviceLevelCode equals "PY". Any advice?

(function executeRule(current, previous /*null when async*/ ) {
    // Get Computer records
    var cmp = new GlideRecord('alm_hardware');
    cmp.setLimit(300);
    cmp.query();
    while (cmp.next()) {
        // Get Serial Number
        var st = cmp.serial_number.toString();
        try {
            var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
            r.setStringParameterNoEscape('id', st);
            r.setHttpTimeout(10000);
            r.setEccParameter('skip_sensor', true);
            var response = r.execute();
            var responseBody = response.getBody();
            var httpStatus = response.getStatusCode();
            gs.info("Status = " + httpStatus);
            gs.info("Response Body = " + responseBody);

            if (httpStatus == '200') {
                var responseObj = JSON.parse(responseBody);
                var arrayl = responseObj[0].entitlements.length;
                for (var i = 0; i < arrayl; i++) {
                    if (responseObj[0].entitlements[i].ServiceLevelCode.indexOf('PY') > -1) {
                        var edate = responseObj[0].entitlements[i].endDate.substring(0, 10);
                        gs.info('THIS IS THE END DATE: ' + edate);
                        cmp.warranty_expiration = edate;
                        cmp.update();
                    }
                }
            } else {
                gs.addErrorMessage('Looks like we ran into a problem.  HTTP status: ' + httpStatus);
            }
        } catch (ex) {
            var message = ex.getMessage();
        }
    }

})(current, previous);
John Schmalhors
Kilo Contributor

This worked:

(function executeRule(current, previous /*null when async*/ ) {
    // Get Computer records
    var cmp = new GlideRecord('alm_hardware');
    cmp.setLimit(300);
    cmp.query();
    while (cmp.next()) {
        // Get Serial Number
        var st = cmp.serial_number.toString();
        try {
            var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
            r.setStringParameterNoEscape('id', st);
            r.setHttpTimeout(10000);
            r.setEccParameter('skip_sensor', true);
            var response = r.execute();
            var responseBody = response.getBody();
            var httpStatus = response.getStatusCode();
            gs.info("Status = " + httpStatus);
            gs.info("Response Body = " + responseBody);

            if (httpStatus == '200') {
                var responseObj = JSON.parse(responseBody);
                var arrayl = responseObj[0].entitlements.length;
				gs.info(arrayl);
                for (var i = 0; i < arrayl; i++) {
                    if (responseObj[0].entitlements[i].serviceLevelDescription.indexOf('ProSupport Plus for PCs and Tablets') > -1) {
                        var edate = responseObj[0].entitlements[i].endDate.substring(0, 10);
                        gs.info("End Date = " + edate);
						cmp.warranty_expiration = edate;
                        cmp.update();
                    }
                }
            } else {
                gs.addErrorMessage('Looks like we ran into a problem.  HTTP status: ' + httpStatus);
            }
        } catch (ex) {
            var message = ex.getMessage();
        }
    }

})(current, previous);
Kai Tingey
Tera Guru

Nice work!

I hadn't even really started looking at it yet lol.

What did you need to change in the REST message to resolve the auth issues?

 

John Schmalhors
Kilo Contributor

1. You'll need to create an OAuth Profile with the application registries. 

note: the "Client Secret" is at the end of the API Key  ********* (1234567) and the "Client ID" is the API Key.

find_real_file.png

2. Endpoint changes:

find_real_file.png

 

3. Now for the GET Authentication settings:

find_real_file.png

 

4. Lastly, the HTTP Request no longer needs the API key since we placed it in the Token Profile:

find_real_file.png

Let me know if you need any more instructions.

Kai Tingey
Tera Guru

Thanks mate, the only change i needed to make was to change the auth method from "inherit from parent" to the existing 0Auth profile in the GET authentication.

Weird that inheriting wasn't working but there you go.

sukran
Mega Sage

@John Schmalhorst - I tried your script , the mentioned script line -index ox ( pro support") is varry from device to device in the response body from dell, some device "ServiceLevelDescrption" were (pro support)

Here below - There are two pro support in the XML file ( one is INItial and extended , so every time its getting updated again and again two days

and some devices only one pro support is there

 

Response Body = [{"","startDate":"2020-04-08T00:00:00Z","endDate":"2023-04-08T23:59:59.000001Z","entitlementType":"INITIAL","serviceLevelCode":"PQ","serviceLevelDescription":"4 Hour ProSupport Plus Mission Critical","serviceLevelGroup":5},{

 

"","startDate":"2020-04-08T00:00:00.557Z","endDate":"2023-04-08T23:59:59.558Z","entitlementType":"INITIAL","serviceLevelCode":"ND","serviceLevelDescription":"Onsite Service After Remote Diagnosis (Consumer Customer)/ Next Business Day Onsite After Remote Diagnosis (Commercial Customer)","serviceLevelGroup":5},

 

{" ","startDate":"2023-04-09T00:00:00Z","endDate":"2025-04-09T23:59:59.000001Z","entitlementType":"EXTENDED","serviceLevelCode":"PQ","serviceLevelDescription":"4 Hour ProSupport Plus Mission Critical","serviceLevelGroup":5}]}]

Inactive_Us1542
Kilo Contributor

Hello All,

 

I am currently working on integrating Tech Direct with ServiceNow and this post has helped me a lot. I am able to receive the response back in the JSON format from which I need to take the enddate field as warranty expiration date.

Now the challenge is that I see more than 4 fields with same enddate label and I need to pull the max value out of it. Please let me know how to get that in a simplified way.

 

Below is the JSON that I received as a response.

 

[{"id":716581973,"serviceTag":"BSFH882","orderBuid":7460,"shipDate":"2015-11-13T19:00:00Z","productCode":"L6002","localChannel":"62181","productId":"latitude-e7450-ultrabook","productLineDescription":"LATITUDE E7450","productFamily":"Unknown","systemDescription":"Latitude E7450","productLobDescription":"Latitude","countryCode":"IN","duplicated":false,"invalid":false,"entitlements":[{"itemNumber":"WXSN111-LC-I","startDate":"2015-11-13T19:00:00Z","endDate":"2016-11-15T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"NBD","serviceLevelDescription":"Next Business Day Onsite Support","serviceLevelGroup":null},{"itemNumber":"WXPN122-LC-I","startDate":"2016-11-15T19:00:00Z","endDate":"2018-11-16T18:59:59.999Z","entitlementType":"EXTENDED","serviceLevelCode":"NBD","serviceLevelDescription":"Next Business Day Onsite Support","serviceLevelGroup":null},{"itemNumber":"WXSP111-LC-I","startDate":"2017-11-15T19:00:00Z","endDate":"2018-11-16T18:59:59.999Z","entitlementType":"EXTENDED","serviceLevelCode":"POW","serviceLevelDescription":"Next Business Day 5x8 Onsite Support - Parts Only","serviceLevelGroup":null},{"itemNumber":"WXPP122-LC-I","startDate":"2015-11-13T19:00:00Z","endDate":"2017-11-15T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"POW","serviceLevelDescription":"Next Business Day 5x8 Onsite Support - Parts Only","serviceLevelGroup":null},{"itemNumber":"WXSF413-LC","startDate":"2015-11-13T19:00:00Z","endDate":"2018-11-15T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"PHONESUPP","serviceLevelDescription":"Limited Technical Phone Support","serviceLevelGroup":null},{"itemNumber":"WXPW213-LC-I","startDate":"2015-11-13T19:00:00Z","endDate":"2018-11-15T18:59:59.999Z","entitlementType":"INITIAL","serviceLevelCode":"PROSUPIT","serviceLevelDescription":"ProSupport Technical Support 7x24","serviceLevelGroup":null}]}]

 

 

Luiz Lucena
Mega Sage

Hello Aditya, 

I'm also trying to get this thing working. Quick question, have you followed this article to the letter or did you do any changes?
I'm not passing the testing phase on HTTP Get Method...

Regarding you question here, you will need to identify which Service Level Code is associated with the warranty.

"serviceLevelCode":"NBD",

"serviceLevelCode":"POW"

 

EDIT: On your case, the Warranty info would be the one associated with 

"serviceLevelCode":"PROSUPIT"

Luiz Lucena
Mega Sage

When using the Authentication type inherited from parent and is not a MID Server, the property below should be checked.
At least here it worked.

find_real_file.png

Luiz Lucena
Mega Sage

Hi @John Schmalhorst , 

This code you mention it worked, where did you use it?

Also, the line below will only work if the script finds "ProSupport Plus for PC's and Tablets", right?

if (responseObj[0].entitlements[i].serviceLevelDescription.indexOf('ProSupport Plus for PCs and Tablets') > -1)

There are computers that doesn't show this, instead they are showing "PROSUPIT", others are showing "ProSupport" only.

Any suggestion how to work around?

Luiz Lucena
Mega Sage

Hi Rick, 

This article is awesome, it shed some light what we can do, however looks like Dell updated how we retrieve the warranty info. 

Would be good to compile an updated version of the process, what do you think?

Thanks!

rhtmalik931
Tera Contributor

Hello John,

 

In the Dell document, it is mentioned that Bearer token is mandatory.

I have applied same setup which is above mentioned by you in screenshots.

But Bearer token is not applied in the Screenshots.

Could you please let me know where i can apply this Bearer token.

Thanks in advance!

Luiz Lucena
Mega Sage

Hello @sukran 

Have you found a way for that EXTENDED issue?

We recently started to see the same happening. One day the expiration date reflects the INITIAL, the other day reflects the EXTENDED one.

Thanks, 

ramansr
Tera Explorer

Hi Rick

 

Would you have any test API keys for warranty that we can use for testing purposes?

Tharun_346
Tera Contributor

 

Hello All,

 

I am currently working on integrating Tech Direct with ServiceNow and this post has helped me a lot. I got the required details from the TechDirect(API key, client ID, secret value), I have created a rest message with required details and endpoints, also created oAUTH profile, for authentication with client ID and secret value,

After the configuration when i have tested, I am getting the below error, Can anyone guide me through this.error message.png

chercm
Mega Sage

@Rick Mann  have any one tried to use Dell case management API with Servicenow ?

 

API SOAP response will contain a <Responses> structure with valid case information. <CaseInfos> structure contains case details.

 

 

<CustomerHeader>
<CompanyName>
API Company, Inc.</CompanyName> <CountryCodeISO>USA</CountryCodeISO>

<EmailOptIn>true</EmailOptIn> <PrimaryContact>

<FirstName>XXX</FirstName> <LastName>YYYY</LastName>

<Country>United States of America</Country> <TimeZone>0500</TimeZone> <PhoneNumber1>11111111111</PhoneNumber1> <EmailAddress>XXX_YYYY@ZZZ.com</EmailAddress> <PreferContactMethod>Email</PreferContactMethod> <PreferLanguage>EN</PreferLanguage>

</PrimaryContact> </CustomerHeader>

<AlertData> <EventId>1</EventId>

<TrapId>0</TrapId>

<EventSource>Client</EventSource>

<Severity>3</Severity>

<CaseSeverity>Medium</CaseSeverity>

<Message> Client Device not booting up. Having Hard Disk Drive issues. Trouble shooting steps – a) Received following message during bootup...ePSA code is ....

</Message> <Timestamp>20120618T020:47:020500</Timestamp> <ServiceTag>XYZ1234</ServiceTag>

 

 

<DeviceName>WorkStation 001</DeviceName> <DeviceIP>84.152.250.84</DeviceIP> <DeviceModel>Latitude E6410</DeviceModel> <DeviceType>UNKN</DeviceType> <OS>Windows Microsoft Windows </OS> <DiagnosticsOptIn>false</DiagnosticsOptIn>

</AlertData>

Steven Parker
Giga Sage

@John Schmalhors 

Did you figure out a solution of the OAuth token expiring and renewing it when a script runs?

Kai Tingey
Tera Guru

Hi All 

 

Quick note on this one, Dell seems to have changed the structure of it's JSON response. I noticed our newer assets weren't returning warranty expirations and the older ones still were. It looks like in some instances the positioning of the warranty date is different in the JSON array. I updated the UI action to look like this:

 

var st = current.serial_number;
var curdate = current.warranty_expiration;

try {
	var r = new sn_ws.RESTMessageV2('DellTechDirect', 'GET');
	r.setQueryParameter('servicetags', st);
	r.setHttpTimeout(10000);
	r.setEccParameter('skip_sensor', true);
	var response = r.execute();
	var responseBody = response.getBody();
	var httpStatus = response.getStatusCode();
	gs.info("Status = " + httpStatus);
	gs.info("Response Body = " + responseBody);
	

	if(httpStatus == "200"){
		var responseObj = JSON.parse(responseBody);
		var edate = responseObj[0].entitlements[3].endDate.substring(0, 10);
		gs.info("end date = " + edate);

		if (edate === undefined){
			var edate = responseObj[0].entitlements[2].endDate.substring(0, 10);
		}
		
		if(curdate == edate){
			gs.addInfoMessage('The Warranty Expiration date is correct');
			action.setRedirectURL(current);
			current.update();		

		}
		if(curdate != edate){
			gs.addInfoMessage('The Warranty Expiration date changed from ' + curdate + ' to ' + edate);	
			current.warranty_expiration = edate;	
			action.setRedirectURL(current);
			current.update();
		}
	}
		else{
			gs.addErrorMessage('Could not retrieve Warranty Expiration information: ' + httpStatus);
			action.setRedirectURL(current);
			current.update();
	}
}
catch(ex) {
	var message = ex.getMessage();
}

 

basically it looks for the date in the original location, and if that comes back as undefined it then looks in the other spot. 

 

This seems to have fixed it.

 

Steven Parker
Giga Sage

@Kai Tingey 

 

Sorry I know this is the 3rd time I have tagged you, but when I edit this post, it deletes it for some reason.

 

I just wanted to see screenshots of the REST Message and the GET Http Request if you could provide those?  Thanks!

Luiz Lucena
Mega Sage

Hey @Steven Parker 

The OAuth token should renew automatically every time the scheduled job runs, 
If you're talking about the message in the yellow box below, that is normal, the token is valid for one hour only. But every time the job runs, it renew it for that hour.
You can also retrieve the token by clicking the link in the related links:

LuizLucena_0-1713971016104.png


If clicking the link returns an error, then you should check with your Dell rep.

Version history
Last update:
‎08-08-2018 11:35 AM
Updated by: