Page Level Script

Posted by Paulh0763 on 09-May-2016 08:23

Good morning,

I could use some help please. I have a lookup field I would like to null out on a page when clicking a workflow action called "Change Branch". I can get that to work using the following code:

<script>
document.getElementById("department_level_3").onchange = type1;
function type1(){
rbf_setFieldValue("department_level_3","");
}
</script>

The Branch Field will null, however, the page will not let me update it to a new Branch as it wants to maintain the null value. Any thoughts on how I can get this working properly?

Thanks, Paul

All Replies

Posted by Mohammed Siraj on 09-May-2016 08:40

Hi Paul,

From the script shared, it looks like you are resetting the same field i.e. '"department_level_3"' on its onchange event handler.

Can you please confirm.

Regards,

Siraj.

Posted by Paulh0763 on 09-May-2016 09:25

Well I know the script needs some love. Probably should be onload instead of onchange? What I need it to do is when the workflow action "Change Branch" is performed, I need that field department to be set to null on the status change page...with the ability to set a new value for the department then save it.

Posted by Mohammed Siraj on 09-May-2016 10:11

Please add the following script to Status Change page (Assuming you are on NewUI):

<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 () {

   rbf_setFieldValue("department_level_3",null); //unset this field

 });

}

catch (err) {

 if (console) {

   console.log(err);

 }

}

</script>

Posted by Paulh0763 on 09-May-2016 10:15

I am currently on 2.2.2.0 but will be upgrading to 4.0 by end of May. Sorry I should have told you the version.

Posted by Mohammed Siraj on 09-May-2016 10:50

Ok. In that case, please add the following script component to you Status Change page:

<script>

$(document).ready(function () {

 rbf_setFieldValue('department_level_3', ''); //unset this field

});

</script>

Note: This is a very generic way of hooking in custom scripts and is not well supported in NewUI pages wherein we have opened up specific API interfaces for the same. Request you to leverage these custom interfaces when upgrading to NewUI.

Also, in NewUI , we have ensured Client-side API, to set,reset, unset fields works well aross all field types.

This thread is closed