Hello,
Is there a URL parameter that can be used to redirect to a specific page onclick on Save?
Basically I am using the 'Mass Update' page, and I want to go back to the previous page (view page of a record), when clicking Save. I tried adding destId and returnId parameters in the URL of the Mass Update page but it's not working.
Any suggestions ?
Cheers,
Meryem
Hi Meryem,
This is not supported OOB. Request you to file an enhancement request in IDEA' s section.
For now, can you try the following scripting solution:
$('form[name="theForm"]').find('input[name="destId"]').val(176735) //176735 is pageId of target page
$('form[name="theForm"]').append('<input name="id" value="395942" type="hidden" />')
// 395942 is recordID.. this parameter is required in case the page mandates a recordId parameter eg. Record Details/View page.
Inside onSaveCancelClick function, you can add a check as follows:
if(document.theForm.act.value === 'Cancel'){
document.theForm.destId.value = '176735';
}else{
document.theForm.destId.value = '176736' ; // something else..
}
Hi Meryem,
This is not supported OOB. Request you to file an enhancement request in IDEA' s section.
For now, can you try the following scripting solution:
$('form[name="theForm"]').find('input[name="destId"]').val(176735) //176735 is pageId of target page
$('form[name="theForm"]').append('<input name="id" value="395942" type="hidden" />')
// 395942 is recordID.. this parameter is required in case the page mandates a recordId parameter eg. Record Details/View page.
Hi Siraj,
Thanks for this. It is working fine.
Now I am trying to do the same on click on Cancel. What is the input that needs to be changed here?
Cheers,
Meryem
It should work for Cancel as well. Please ensure that you are doing the modification on form submit, so that they are not overwritten elsewhere in code.
Have got the following snippet working well for me on both form submit & cancel:
<script>
try {
if (!rbf_isNewUI()) {
throw 'This Script is written specific to New UI Context';
}
var formContext = rbf_getObjectRecordForm();
if (formContext) {
rb.newui.util.addEventListener(rb.newui.util.customEvents.rbs_pageRender, function () {
//Get formContext instance for Edit Form in page
formContext.addSubmitHandler(onFormSubmit);
});
}
function onFormSubmit(event) {
var formEl = formContext.getFormNode();
if (formEl) {
formEl.find('input[name="destId"]').val(176735) //176735 is pageId of target page
formEl.append('<input name="id" value="395942" type="hidden" />')
// 395942 is recordID.. this parameter is required in case the target page mandates
//a recordId parameter eg. Record Details/View
}
};
}
catch (err) {
if (console) {
console.log(err);
}
}
</script>
Right, this solution will not work on 4.0.4, as form submit handlers are not invoked for cancel. This was an intermittent issue in 4.0.4, that was resolved in 4.0.5.
For now, can you please try:
<script>
try {
if (!rbf_isNewUI()) {
throw 'This Script is written specific to New UI Context';
}
rb.newui.util.addEventListener(rb.newui.util.customEvents.rbs_pageRender, function () {
var kToolbar = $('div.rbs-pageheader-toolbar').data('kendoToolBar');
if (!kToolbar) {
return;
}
var opts = kToolbar.options;
opts.click = function () {
//intercept click event...
onSaveCancelClick();
return false;
};
kToolbar.setOptions(opts);
});
function onSaveCancelClick() {
var formContext = rbf_getObjectRecordForm();
var formEl = formContext.getFormNode();
if (formEl) {
formEl.find('input[name="destId"]').val(176735);//dest page id...
formEl.append('<input name="id" value="395942" type="hidden" />');//dest page.. record Id..
document.theForm.destId.value = '176735';
formEl.submit();//re-submit... for these values to take affect
}
};
}
catch (err) {
if (console) {
console.log(err);
}
}
</script>
Hi SIraj,
Thanks for this it is working fine. But the requirement has evolved a bit.
We need to redirect one view page on Save, and to ANOTHER view page on Cancel. So we need the same code but need to differentiate Cancel from Save click.
What is the best way to do this please?
Cheers,
Meryem
Inside onSaveCancelClick function, you can add a check as follows:
if(document.theForm.act.value === 'Cancel'){
document.theForm.destId.value = '176735';
}else{
document.theForm.destId.value = '176736' ; // something else..
}
It is working Siraj.
Thanks :)
Meryem