logo

NJP

Auto Launch Guided Tours - Conditionally

Import · Jul 08, 2018 · article

Hello everyone in the community.

I would like to share a code snippet which I was using to help achieve a use case of mine and thought it would be helpful to share and could help someone achieve a similar use case.

Use Case: Auto Launch a Guided Tour (This is available in Kingston though). But I didn't find an option to restrict the autolaunch based off a condition on the form.

The below is a piece of code which can be used inside a client script.

//If the current state of the form meets your conditions, launch the tour
if(g_form.getValue('some_field') == 'some_value'){

top.NOW.guidedToursService.startTour("sys_id_of_guided_tour_to_be_launched", 0);
//(sys_id of the guided tour you want to launch, step#)

//Check if the guided tour is dismissed by the user, if so then end the tour. 
//If not the system will dispaly a message if the user navigates to a different form
//before the completion of the guided tour.

    setInterval(function(){
        if(top.NOW.guidedToursService.isDismissed){
            top.NOW.guidedToursService.endTour(); 

            clearInterval();
        }

    },2000);
}

The above uses the window.top properties that the instance uses internally to launch the guided tour.

I shall try to update this article if I find any other better solutions if at all not using the window properties.

View original source

https://www.servicenow.com/community/now-platform-articles/auto-launch-guided-tours-conditionally/ta-p/2305692