Service Operations Workspace Experience with UI Builder Customization Issue

Voona Rohila
Kilo Patron
Kilo Patron

Hi Everyone

I am stuck on a issue and need your inputs/resolution for this.

 

On Service Operations Workspace - Change module when we click on 'Create New' button, create-change-request-page is opened and User can select the template/model and click on Next Button which closes the current tab and opens the New Change record with pre filled details.

 

Current Page :

VoonaRohila_0-1686925473247.png

 

 

My requirement is to skip the clicking of Next Button and directly redirect to next page when Template is clicked.

 

I've created a duplicate of the OOTB variant and tried this

1. I deleted Next & Cancel Button component in Button Container Component.

2. I added Event Handler on Card Base Container 1 to Execute - Client Script Close Tab and Execute -Client script on Next Button so that when card is selected the next button code executes.

 

VoonaRohila_2-1686925501504.png

 

 

The above configuration is closing the tab and opening change form but the pre-populated fields are not setting up properly.(I am clicking standard template but Type is being set as normal and sometimes it is setting up the previously selected template values.)

 

I am new to UI Builder so any input will be helpful.

 

Thank You in advance.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
5 REPLIES 5

jMarshal
Mega Sage
Mega Sage

I think you need to keep the code for the "Pin/Unpin" script in the actions for when you click on card...that way the "Next Button" client script has the parameters you're looking for (this is why it is sometimes the same parameters as a previous template -- they're present, but not getting passed by the Pin/Unpin as you desire).

I am using the same client script that was used on OOTB 'Next' Button Event in the Event Handler 

OOTB Next Button Click:

VoonaRohila_2-1686936462875.png

Card Selection Event click :

VoonaRohila_0-1686936818132.png

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Yes, but you need the other one too (you need 3 events handlers for this, on the card selection click)

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 * @Param {ApiHelpers} params.helpers
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    let models = JSON.parse(JSON.stringify(api.state.models));
    let filter = JSON.parse(JSON.stringify(api.state.searchInfo.selectedFilter));
    let pinnedArray = models.pinned.split(",");

    //Update base models
    models.chgModels.forEach(function(model, index) {
        if (model.sysId === event.context.item.value.sysId) {
            let pinnedIndex = pinnedArray.indexOf(model.sysId);

            if (model.isPinned) {
                if (filter === 'pinned') {
                    models.chgModels.splice(index, 1);
                    --models.totalCards;
                } else {
                    model.isPinned = false;
                    model.pinIcon = [{
                        "icon""thumbtack-outline",
                        "label": models.pinLabels.pin
                    }];
                }
                if (pinnedIndex > -1) {
                    pinnedArray.splice(pinnedIndex, 1);
                }
            } else {
                model.isPinned = true;
                model.pinIcon = [{
                    "icon""thumbtack-fill",
                    "label": models.pinLabels.unpin
                }];
                pinnedArray.push(model.sysId);
            }
        }
    });

    models.pinned = pinnedArray.join();
    api.setState("models", models);

    api.emit("UPDATE_USER_PINNED_PREFERENCES", {});
}

which is on the pin/update card:

jMarshal_0-1686937306932.png



keep that action (execute client script pin unpin card) at the top of the "events" you copied from the next button.




Hi @jMarshal 

I tried and It's always taking the default change model on any card click.

VoonaRohila_0-1687156505755.png

Also added Card Click client script so that the values for 

selectedCard are being set but same issue.

VoonaRohila_1-1687159268217.png

 

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP