How to implement an Alert in Change Request?

Meera_P
Tera Expert

Hi,

How to implement an Alert in Standard Change Request only when state changes to "Implement"?

I need to reminder the requestor to add an attachment.  Thank you

 

 

Meera_P_0-1711603485691.png

 

15 REPLIES 15

Sujatha V M
Kilo Patron
Kilo Patron

@Meera_P 

 

Assuming attachments could have been added prior to the state that you are requesting for. 

 

You just need an alert to remind that an attachment needs to be added in that state or check if there are any attachments on the record and alert again? 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.




 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Hi @Sujatha V M ,

I need to check an attachment on the "Implement" status, if not, display the Alert.

Here is the code I have tried, but it is failing, because I don't think I can use 'current" in client scripts

Meera_P_0-1711606744097.png

var stateStatus = g_form.getValue('state');
    if (stateStatus == '-1') {
        var attachment = new GlideRecord('sys_attachment');
        attachment.addQuery('table_name', 'change_request');
        attachment.addQuery('table_sys_id', current.sys_id);
        attachment.addQuery('type', 'standard');
        attachment.query();
        if (!attachment.next()) {
            alert("Please include attachment");
            return false;
        }

No you shouldn't use "Current" in Client scripts. If you want retrieve a server side value use GlideAjax. 

 

Note: I would request you go with "Script Include" and avoid using GlideRecord in client scripts. 

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

@Sujatha V M 

Can we modify the code to make it works in Client Scripts or I have to use GlideAjax in this case?