- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 10:14 AM
I have a requirement. in catalogue form If a user requests for a domain name which is available in 'NameStudio® API: A Smart API Solution That Delivers Relevant Domain Name Suggestions (namestudioapi....' it has to be populated in the catalogue variable field if not available in else it should populate error message.
I have created a catalogue and created a script include and catalogue client script below.
But it is not working please suggest me the right approach.
Thanks in advance.
Script include:
Client script:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 11:34 AM
@Chandrashekar_N Are you sure if you are calling the right end point. I checked https://namestudioapi.com/' and found that it has a suggest API hosted at this URL https://sugapi.verisign-grs.com/ns-api/2.0/suggest?name=google here google is the actual domain name to check.
Here is the response sample.
results": [
{
"name": "ShGoogle.com",
"availability": "available"
}
According to this you need to update your scripts as follows.
Script Include:
var DomainAvailabilityCheck = Class.create();
DomainAvailabilityCheck.prototype = {
initialize: function() {},
checkAvailability: function(domainName) {
try {
var domainName = this.getParameter('sysparm_domainName');
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://sugapi.verisign-grs.com/ns-api/2.0/suggest?name=' + domainName);
request.setHttpMethod('GET');
var response = request.execute();
var responseBody = response.getBody();
var responseObj = JSON.parse(responseBody);
return responseObj.results[0].availability; //property name is availability also response returns a result array
} catch (ex) {
gs.error('Error in DomainAvailabilityCheck Script Include: ' + ex.message);
return false;
}
},
type: 'DomainAvailabilityCheck'
};
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Make a GlideAjax call to the Script Include
var ga = new GlideAjax('DomainAvailabilityCheck');
ga.addParam('sysparm_name', 'checkAvailability');
ga.addParam('sysparm_domainName', newValue);
ga.getXMLAnswer(function(response) {
var isAvailable = response.responseXML.documentElement.getAttribute("answer") == 'available';
var message = isAvailable ? 'Domain is available' : 'Domain is not available';
// Display the message to the user
g_form.showFieldMsg('domain_avaliablity', message, 'info');
});
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 11:34 AM
@Chandrashekar_N Are you sure if you are calling the right end point. I checked https://namestudioapi.com/' and found that it has a suggest API hosted at this URL https://sugapi.verisign-grs.com/ns-api/2.0/suggest?name=google here google is the actual domain name to check.
Here is the response sample.
results": [
{
"name": "ShGoogle.com",
"availability": "available"
}
According to this you need to update your scripts as follows.
Script Include:
var DomainAvailabilityCheck = Class.create();
DomainAvailabilityCheck.prototype = {
initialize: function() {},
checkAvailability: function(domainName) {
try {
var domainName = this.getParameter('sysparm_domainName');
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://sugapi.verisign-grs.com/ns-api/2.0/suggest?name=' + domainName);
request.setHttpMethod('GET');
var response = request.execute();
var responseBody = response.getBody();
var responseObj = JSON.parse(responseBody);
return responseObj.results[0].availability; //property name is availability also response returns a result array
} catch (ex) {
gs.error('Error in DomainAvailabilityCheck Script Include: ' + ex.message);
return false;
}
},
type: 'DomainAvailabilityCheck'
};
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Make a GlideAjax call to the Script Include
var ga = new GlideAjax('DomainAvailabilityCheck');
ga.addParam('sysparm_name', 'checkAvailability');
ga.addParam('sysparm_domainName', newValue);
ga.getXMLAnswer(function(response) {
var isAvailable = response.responseXML.documentElement.getAttribute("answer") == 'available';
var message = isAvailable ? 'Domain is available' : 'Domain is not available';
// Display the message to the user
g_form.showFieldMsg('domain_avaliablity', message, 'info');
});
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:20 AM
Thanks for your input. I have tried your suggestion but it did not worked. please let me know what I have to do to achieve functionality.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:16 AM
Your solution really worked of my requirment.
Thankyou so much for your valuable feedback.