Playbook Attachments Mandatory

Jamest1980
Tera Contributor

Hello, I'm wanting to make adding an attachment to the playbook activity mandatory. As in the User can not move on to the next activity until an attachment is attached and a notification pops up informing the User of this requirement. Does anyone know how I can make this happen? I was told that maybe using UI Policies in combination with Client Scripts but I have not been successful. Currently I can add attachments, but I can't make them Mandatory. 

5 REPLIES 5

folusho
Tera Guru

@Jamest1980 

 

Please try this:

 

1. Create a UI script called: "setAttachmentMandatory". Set UI Type to "All".

Put this in the script section.

 

(function() {
    "use strict";

    return {

        setAttachmentMandatory: function(isMandatory) {
            var isSuccess;
            try {
                angular.element("#sc_cat_item").scope().c.data.sc_cat_item.mandatory_attachment = isMandatory;
                isSuccess = true;
            } catch (e) {
                isSuccess = false;
                //gs.log('setAttachmentMandatory() failed: ' + e);
            }

            return isSuccess;
        },

        type: "AttachmentUtil"
    };
})();

 

2. Then create client script/UI Police (as you may wish)... and add this script:

Make sure to check the "isolate script" and set UI Type to "All"

 

if (g_form.getValue('test') == 'Yes') {
    g_ui_scripts.getUIScript('setAttachmentMandatory').then(function (script) {
        script.setAttachmentMandatory(true);
    });
} else {
    g_ui_scripts.getUIScript('setAttachmentMandatory').then(function (script) {
        script.setAttachmentMandatory(false);
    });
}

 

Thank you I'll give this a try and report back in a day or so. 

Thank you folusho! only one questions, for the client script/UI policy, what table does this need to be created on, we are creating the playbooks off of the 'pm_project_task' table but the playbook activity cards are captured on an entirely separate table here 'sys_pd_activity_context'. With that being said after creating the UI script, could you provide some guidance on what to do with the clientscript/ui policy

valter479
Tera Contributor

Hi @Jamest1980 ,

 

Did you have a solution?

 

Thanks