Skip to main content
Kinetic Community

Passing information from one Service Item to Another

How to pass information from one Service Item to another using variables in the URL.

Description

A customer recently asked for a way to allow the Requestor to Submit a Service Item and then be able to retreive those submitted Answers and Submit another Request.  They were looking for a way to have a rapid submission of Requests that were all very similar (PC Request with the same hardware configuration but different software) for a number of different users.  To solve the problem I have developed two Serivce Items that will Share data via the URL.

I have built two Service Items called:

Passing Data via URL

Receiving Data via URL

The Passing Data via URL is a very simple Service Item in that it only contains two Questions and one Text element.  The Questions are Name and Description.  The Text element contains syntax to display a button.  This Text element contains the following Event:

Event:  click

Action:  Custom

Action Name:  Open Receiving Service Item

Custom Code:

openReceivingData();

The openReceivingData(); function is defined in the CustomHeaderContent field and has the following syntax:

function openReceivingData(){
    name = KD.utils.Action.getQuestionValue("Name");
    description = KD.utils.Action.getQuestionValue("Description");
    var url = ("DisplayPage?name=ReceivingData&name=" + name + "&description="+description);
    window.open(url, '_default', 'toolbar=yes, directories=no, location=yes, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=1000, height=600');
}

 

Lines 2 and 3 is the syntax used in order to return the Answers to the Name and Description questions.  Line 4 is used to call the URL to the other Service Item and then add the Name and Description questions/answers.  Note that to make the function easier I gave the Receiving Data via URL Service Item a value (ReceivingData) in the Display Name For URL field (located on the Advanced tab).

There is also one Event built on the Initial Page.  This Event Removes the Submit button from the Page.  This is required as we don't actually want the end user to submit the Passing Data via URL Service Item.

The Receiving Data via URL Service Item contains three Questions.  The Questions are Name, Description, and Type of Request.  Note that the Name and Description Questions will be populated based on the Data in the Passing Data via URL Service Item.  In order to populate the Name and Description Questions the following Event was built on the Initial Page:

Event:  load

Action:  Custom

Action Name:  Set values

Custom Code:

var ksrID = KD.utils.Util.getParameter('name');
if (name) {

    KD.utils.Action.setQuestionValue('Name', decodeURIComponent(KD.utils.Util.getParameter('name')));
    KD.utils.Action.setQuestionValue('Description', decodeURIComponent(KD.utils.Util.getParameter('description')));
   }

This function is used in order to Set the Name and Description Questions/Answers based on the data held in the URL.