4.0.4 - Redirect to view page from Mass Update Page

Posted by Meryk on 04-Mar-2016 08:42

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

Posted by Mohammed Siraj on 07-Mar-2016 04:07

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.

Posted by Mohammed Siraj on 09-Mar-2016 23:41

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..

}

All Replies

Posted by Mohammed Siraj on 07-Mar-2016 04:07

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.

Posted by Meryk on 08-Mar-2016 09:02

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

Posted by Mohammed Siraj on 08-Mar-2016 21:30

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>

Posted by Mohammed Siraj on 09-Mar-2016 07:17

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>

Posted by Meryk on 09-Mar-2016 11:18

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

Posted by Mohammed Siraj on 09-Mar-2016 23:41

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..

}

Posted by Meryk on 10-Mar-2016 08:57

It is working Siraj.

Thanks :)

Meryem

This thread is closed