Thursday, December 27, 2018

Supported client scripting APIs & Unsupported client scripting global in Service Portal

Service Portal runs client scripts & catalog client scripts as long as the UI Type is set to "Mobile" or "Both". Many of your existing client scripts can be set to "Both" if the API calls are supported by the mobile client scripting environment.
Please note: This document applies to the Form widget and SC Catalog Item widget. Client Scripts are different than a widget's client controller & link script blocks.

Unsupported client scripting global
The following global and APIs are unavailable in-service portal client script:
window
document
$
jQuery
$$
$j
angular

Client scripting in widgets
Widget client controllers are full angular controllers and are not subject to the restrictions listed above. Feel free to use jQuery and Angular as needed.

Embedded widgets & g_form
When using the Service Catalog variable type "Macro" and "Macro with Label" you can pick a widget to embed in a catalog item form. Within that embedded widget's client controller, you can access the field object and catalog item g_form instance using:
$scope.page.field
$scope.page.g_form()

Checking desktop vs mobile runtime
You might want to mark a client script compatible with both Desktop and Mobile but still do something different depending on the runtime use this:

  if (window === null)
    // Write your mobile compatible code here
  else
    // Write your desktop compatible code here
Supported client scripting APIs
These are the officially supported client scripting APIs you can use in onLoad, onChange, and onSubmit client scripts.

g_form
addDecoration(fieldName, icon, title)
addErrorMessage(message)
addInfoMessage(message)
addOption(fieldName, value, label, index)
clearMessages()
clearOptions(fieldName)
clearValue(fieldName)
getActionName()
getBooleanValue(fieldName)
getDecimalValue(fieldName)
getDisplayValue(fieldName)
getEncodedRecord()
getFieldNames()
getIntValue(fieldName)
getLabel(fieldName)
getReference(fieldName, callback)
getRelatedListNames()
getSectionNames()
getSysId()
getTableName()
getValue(fieldName)
hasField(fieldName)
hideAllFieldMsgs(type: "info | error")
hideErrorBox(fieldName)
hideFieldMsg(fieldName, clearAll)
hideRelatedList(listTableName)
hideRelatedLists()
isMandatory(fieldName)
isNewRecord()
isReadOnly(fieldName)
isVisible(fieldName)
removeDecoration(fieldName, icon, title)
removeOption(fieldName, value)
save()
serialize(onlyDirtyFields)
setFieldPlaceholder(fieldName, placeholder)
setLabel(fieldName, label)
setMandatory(fieldName, isMandatory)
setReadOnly(fieldName, isReadOnly)
setSectionDisplay(sectionName, isVisible)
setValue(fieldName, value, displayValue)
setVisible(fieldName, isVisible)
showErrorBox(fieldName, message, scrollForm)
showFieldMsg(fieldName, message, type: "info | error", scrollForm)
showRelatedList(relatedTableName)
showRelatedLists()
submit(submitActionName)

g_list
get(fieldName)
addItem(value, displayValue)
removeItem(value)
reset()
setQuery(queryString)
setDefaultOperator(operator)
getDefaultOperator()

g_service_catalog
isOrderGuide()

GlideAjax
new GlideAjax(scriptIncludeName)
addParam (name, value)
getParam (name)
getXML(callback)
getXMLAnswer(callback)
getJSON(callback)
setErrorCallback(errorCallback)
getURL()
getParams()
execute()
successCalback(data, status, xhr)
errorCallback(xhr)
setScope(scope)

GlideRecord
new GlideRecord(tableName)
addQuery(encodedQuery)
addQuery(fieldName, operator, value)
getEncodedQuery()
deleteRecord(callback)
get(id)
getTableName()
hasNext()
insert(callback)
gotoTop()
next()
loadRow(rowObj)
getValue(fieldName)
setValue(fieldName, value)
isDotWalkField(fieldName)
addOrderBy(fieldName)
orderBy(fieldName)
orderByDesc(fieldName)
setDisplayFields(fieldNames)
query(callback)
setRows(rowsArray)
setTableName(tableName)
update(callback)
setLimit(maxInt)
getLimit()

getMessage(messageKey, callback)

Usage examples

g_list
g_list helps you set the filter of a glide list element or a list collector variable. Use this API in place of the "g_filter" API on desktop client scripts.

function onLoad() {
  var myListCollector = g_list.get("my_list_collector");
  myListCollector.reset();
  myListCollector.setQuery("active=true^category=8c7b22230b402200b0b02c6317673a62");
  myListCollector.addItem('3a700d39af5f4fc0aab978df90f4c692', 'Power Supply');
  myListCollector.addItem('1cb93419a3a248318da8f814140b42f6', 'Backpack');
}

g_service_catalog
g_service_catalog is only available in Service Portal service catalog item scripts. Use this API to know if your catalog item script is being run as part of an order guide or on its own.

 function onLoad() {
   if (window) // if CMS don't run this
    return;

    // g_service_catalog api for Service Portal and Mobile
    var isOrderGuide = g_service_catalog.isOrderGuide();
    g_form.setValue("is_order_guide", isOrderGuide ? "Yes!" : "Nope :(");
}

Tuesday, November 27, 2018

Require attachment for catalog item in Platform and Service Portal

Follow the below steps:-

1.Create UI Script

UI Script: GlobalCatalogItemFunctions
Global: true
Script:

function getSCAttachmentCount() {
   var length;
   try {
   length = angular.element("#sc_cat_item").scope().attachments.length;
   } catch(e) {
   length = -1;
   }
   return length;

}


2. Select your Portal > Theme(Open the theme and go to the related list section, click JS include tab and click the new UI action). 

Create New:- JS Theme

Display Name:- GlobalCatalogItemFunctions

Source:- UI Script

UI Script: GlobalCatalogItemFunctions(Select the UI script that is you created)


3. Catalog Client Script:

function onSubmit() {

   //Works in non-portal UI

   try {

   var attachments = document.getElementById('header_attachment_list_label');

   if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {

   alert('You must attach the completed form before submitting this request.');

   return false;

   }

   }

   //For Service Portal

   catch(e) {

   var count = getSCAttachmentCount();

   if(count <= 0) {

   alert('You must attach the completed form before submitting this request.');

   return false;

   }

   }

}

Tuesday, October 9, 2018

Prevent users from following records in Connect for a specific table

Users can follow records in Connect for any table that extends Task [task] by default. You can disable this functionality for a specific table.

To disable record conversations for a specific table, prevent the Follow button from appearing in form headers for the table. To do so, set the live_feed dictionary attribute to false for the table.

Procedure
  1. Navigate to the list view of a table for which you want to disable record conversations.
  2. Right-click any column header.
  3. Select Configure > Dictionary.
  4. The list of dictionary entries for the table appears.
  5. Open the dictionary entry that has Type set to Collection.
  6. The Dictionary Entry form appears.
  7. In the Attributes related list, locate the Live feed dictionary attribute.
  8. Set the Value to false.

Thursday, September 20, 2018

Demystifying GlideAjax (Infographic)






Let's face it, unless you're a web developer who has been on the AJAX bandwagon for a while, GlideAjax can be downright confusing.  At best, it is often a mystical voodoo incantation, sure you can say the words but your just one "Klaatu verata necktie" away from unleashing a horde of undead code that will leave you wanting to unload a fist full of boomstick on your computer.  With that in mind, I have put together the infographic below to illuminate your path, equip you for the debugging battles ahead, and return you to your time.  Or return to you, your time.  Whichever.

Saturday, September 15, 2018

Servicenow Tutorial for Beginners - Servicenow Basic

ServiceNow Tutorial for Beginners - ServiceNow Basic 

What is ServiceNow


ITIL v3 + Web 2.0 + SaaS = Service-now.com, a pioneer of On Demand IT Service Management combines ITIL v3 guidelines with Web 2.0 technology to a Software as a Service offering.
As we have seen in many cases customers of SaaS providers are increasingly asking for identity and access management features for convenience and security. To meet these requirements Service-now.com added SAML v2 support to their Spring 2010 release. This is in line with what we have seen at other important SaaS players like Salesforce.com who added SAML 1.1 support in the Summer 2008 release and SAML 2.0 later. Demonstrating once more that SAML 2.0 is a must-have in the enterprise SaaS world.
ServiceNow is a leading provider of cloud-based services that automate enterprise IT operations. We focus on transforming enterprise IT by automating and standardizing business processes, transforming IT's relationship with its customers, and consolidating IT across the global enterprise. Organizations deploy our service to create a single system of record for enterprise IT, lower operational costs and enhance efficiency. Additionally, our customers use our extensible platform to build custom applications for automating activities unique to their business requirements.

What Do I Get with ServiceNow?


ServiceNow offers the following services and benefits. On-demand IT Service Management and  IT governance functions Guaranteed performance, availability, and continuity of service Data confidentiality and data integrity ServiceNow will continue to experience rapid growth in coming years, spurred by its customer-centric approach, its expanding portfolio and it's experienced management team. By expanding its portfolio, ServiceNow will maintain its disruptive ITSM position while diversifying revenue. After hiring members of Data Domain’s ex-management team, including Slootman, in 2H11 and more than doubling its headcount, ServiceNow has the technology and bodies in place to succeed in coming years. Data Domain is an IT company that experienced a growth curve similar to that of ServiceNow, giving its management team experience in growing small companies into enterprises. As customers’ comfort with cloud increases, ServiceNow will continue eroding BMC’s and HP’s traditional ITSM solutions throughout 2012 and will begin to disrupt IBM’s ITSM customer base in coming years. The SaaS-based ITSM market, although currently only an estimated 7 percent of the total ITSM market, is quickly growing. Disruptive vendors like ServiceNow are capitalizing on the market’s growth, driven by customer demand for cloud. However, ServiceNow will face headwinds in addressing more complex IT environments such as hybrid, on-premise hosted or mainframe environments where competitors maintain a strong footprint.

Thursday, September 13, 2018

How to communicate two different widgets in a page

How to communicate two different widgets in a page

Step 1: Create a widget and give the name as per your choice, and insert below code of your widget.

HTML PART :-

<div class="panel panel-default">
  <div class="panel-body">
  <div class="form-group">
    <label>Title</label>
    <input class="form-control" ng-model="c.data.name">
    </div>
    <div class="form-group">
   
      <lable>Description</lable>
      <input class="form-control" ng-model="c.data.sdec">
    </div>
    <div class="form-group">
   
      <input class="btn btn-primary btn-block" ng-click="c.addItem()" type="submit" value="Add">
    </div>
  </div>
</div>

SERVER SCRIPT:-

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
if(!input)
return;
var gr=new GlideRecord("<your tbl name>");
gr.initialize();
gr.variable_name=input.name;
gr.varaible_name=input.sdec;
gr.insert();
})();

CLIENT SCRIPT :-

function() {
  /* widget controller */
  var c = this;
c.addItem=function()
{
c.server.update().then(function(response){
c.data={};
})
  }
}

Step 2: Create the second widget and give the name as per your choice, insert the following code.

HTML PART :-

<div class="panel panel-default">
  <div class="panel-heading">
  TASK
  </div>
 <div class="list-group">
  <a class="list-group-item" ng-repeat="task in c.data.tasks">
   <input class="pull-left" type="checkbox">
    <div class="m-l-lg">
      <b class="text-primary">{{task.name}}</b><br>
  {{task.description}}
    </div>
   </a>
  </div>
  <div ng-if="c.data.tasks.length==0" class="b-t wrapper text-center">NO TASK</div>
</div>

SERVER SCRIPT:-

(function() {
 data.tasks=[];
var gr=new GlideRecord('<tbl_name>');
gr.query();
while(gr.next())
{
var task={};
task.name=gr.getDisplayValue('variable_name1');
task.description=gr.getDisplayValue('variable_name2');
task.sys_id=gr.getUniqueValue();
data.tasks.push(task);
}
})();

CLIENT SCRIPT:-

function($scope,spUtil) {
  /* widget controller */
  var c = this;
spUtil.recordWatch($scope,"<tbl name>","",function(name,data){
spUtil.update($scope);
});
}


Step 3:- Create a page and add both the widget inside the page.

Step 4 :-  Test







Tuesday, September 11, 2018

Use the Customer Service case timeline with other applications

Use the Customer Service case timeline with other applications


You can use the Customer Service case timeline with other ServiceNow applications by creating a configuration for each application and adding the ResolutionShaper field to the desired form.

Procedure :-

1. Ensure that the Customer Service plugin (com.sn_customerservice) has been activated.

2. Navigate to the Resolution Shaper Configs page (<instance>sys_resolutionshaper_config_list.do) and click New.

3. Select a table in the Task Table field.

4. Add the desired states in the Requestor States field using a comma-separated list. For example, (New, Active, Resolved, Closed).

5. Make any necessary changes to the remaining fields and click Submit.

6. Navigate to the desired form.

7. Right-click the form header and select Configure > Form Layout.

8. Using the slushbucket, select ResolutionShaper and move it to where you want the timeline to appear.


9. Click Save.


What’s New in Kingston: Customer Service Management Deep Dive.


What’s New in Kingston: Customer Service Management Deep Dive.

Please click below link.

Click Me...

Monday, September 10, 2018

How to Make Variables Read Only Using g_form in ServiceNow

Variables Read Only

1. I was recently working with a colleague who mentioned that he had seen a new (un-documented) g_form method which allows you to set all catalog item Variables to Read Only.

2. Perform this trick (makes it so fulfillers of tasks update variables but they can’t be updated from the catalog item request). 

Use the below code on your catalog client script :-

g_form.setVariablesReadOnly(true);

Saturday, September 8, 2018

Enable electronic signature for approval

This topic explains how to enable electronic signatures for approval. Electronic signatures are helpful if you must obtain a digital signature for compliance or auditing purposes.

You can activate the Approval with e-signature to require that users type in a username and password when reviewing and approving documents.

The digital signature is not tracked or stored in the document record. Users must simply type in a username and password after clicking the Approve or Reject button.

Digital signature












After activating the Approval with E-Signature plugin, ensure that a row in the e-signature registry table is created for the dms_document_revision table.

Procedure
  1. Navigate to System Definition > e-Signature Registry.
  2. Check if dms_document_revision is already listed and Enabled is set to true.
  3. If not listed, click New.
  4. In Table name, select Document Revision.
  5. Select Enabled.
  6. Click Submit.