Perform a click on the Clone button

Posted by IramK on 09-Mar-2016 04:35

Hello,

Is there a way I could perform a click on the Clone button on the View page automatically using javascript? Kindly let me know.

Cheers.

Iram

All Replies

Posted by Mohammed Siraj on 09-Mar-2016 04:59

Rollbase is not really open to this level of customization. Request you to file an Enhancement Request in IDEAS section for the same.

However, you can employ the following scripting solution to make it work.

var kToolbar = $('div.rbs-pageheader-toolbar').data('kendoToolBar');

if(!kToolbar){

return;

}

var opts = kToolbar.options;

opts.click = function(e){

//intercept click event...

console.log("click", e.target.text());

return false;

};

kToolbar.setOptions(opts);

Posted by IramK on 09-Mar-2016 05:33

Hello [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05],

This doesn't really answer my question. The Clone button is by default not visible and doesn't appear in the DOM unless and until we click on the three dotted dropdown button. Is there a function that is being called when the Clone button is clicked like "rbf_cloneRecord()..."? I could probably use that rather than perform a click on the clone button programmatically. Any suggestions?

Cheers.

Iram

Posted by Mohammed Siraj on 09-Mar-2016 06:36

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 Mohammed Siraj on 09-Mar-2016 07:18

For ability to trigger a click, this is a limitation in Rollbase as of now. Request you to file an enhancement.

Posted by IramK on 09-Mar-2016 10:18
This thread is closed