Don't close the page after saving

Hi Community,

 

How can I do in the new Freedom Ui so that the page does not close after saving a record?

I know the method in the old classic page, but I can't find the way to do it in the new Freedom ui.

 

Thank you in advance.

Like 2

Like

4 comments

This works, but does produce some odd results on some pages - for example the Case page shows several things once the CreatedOn is populated and it appears that the data isn't reloaded after the save. So you'd probably also have to do a reload in addition to this: 

{
    request: "crt.SaveRecordRequest",
    handler: async (request, next) => {
        request.preventCardClose = true;
        return next.handle(request);
    }
}

Ryan

Thanks for sharing Ryan

Ryan Farley,

Hi Ryan,
is there a way to stay on the page of a newly created Case record, but having the page reloaded after the case number has been generated?
Currently I'm just staying at the Case page, but the case number and resolution time don't show up.

Thank you in advance

Alex Parkhomchuk,

It works to follow up the save with a refresh. Something like this:

{
    request: "crt.SaveRecordRequest",
    handler: async (request, next) => {
        // don't close page
        request.preventCardClose = true;
 
        const result = await next.handle(request);
 
        // reload if adding
        const cardState = await request.$context.CardState;
        if (cardState == "add" || cardState == "copy") {
            request.$context.executeRequest({
                type: "crt.LoadDataRequest",
                $context: request.$context,
                config: {
                    loadType: "reload",
                    useLastLoadParameters: true
                },
                dataSourceName: "PDS"
            });
        }
 
        return result;
    }
}

However, although it works, the URL still says it's in add mode (showing #Card/Cases_FormPage/add), even though it's not. A hacky alternative is to just navigate to the edit page of the case from the save. 

{
    request: "crt.SaveRecordRequest",
    handler: async (request, next) => {
        // don't close page
        request.preventCardClose = true;
 
        const result = await next.handle(request);
 
        // re-open in edit if adding
        const cardState = await request.$context.CardState;
        if (cardState == "add" || cardState == "copy") {
            const caseId = await request.$context.Id;
            request.$context.executeRequest({
                type: "crt.UpdateRecordRequest",
                entityName: "Case",
                $context: request.$context,
                recordId: caseId
            });
        }
 
        return result;
    }
}

I tried changing the page to edit mode in the save (changing action and recordId in the modelInitConfigs), but this doesn't seem to do anything in the save, likely only works in the init

Ryan

Show all comments