Create Application Menu's dynamic module

quangminh_doan
Tera Contributor

Hi experts,

I have read some other posts about dynamic module within the Application Menu, but none of them help me solve my problem.

 

1. I have a list of Skill Evaluation Submission. The Submission's fields are as below:

quangminh_doan_0-1675000296368.png

 

2. I have 3 groups which are: SE User, SE PM, SE CoE

 

I need to create a module shows a list of Submission record, where:

  • Records with state = "Submitted" should be visible to users in SE PM group
  • Records with state = "Reviewed" should be visible to users in SE CoE group

 

I really appreciate your help

1 ACCEPTED SOLUTION

Hi @quangminh_doan ,

 

You can achieve it with script:

In script include create a function with code as below:

If current user belongs to SE PM group then var enqr= (state = "Submitted")

Else if current user belongs to  SE CoE group then enqr = (state="Reviewed"). 

 

Then create a GlideRecord query on submission table.

Use the same encoded query. 

Then push the sys_id in an array and return it.

 

This will allow you to have different set of sysId.

 

 

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

View solution in original post

7 REPLIES 7

Rajat_Choudhary
Tera Expert

Hello @quangminh_doan ,

 

You can achieve it using a before query business rule.

 

In Advance script check

If current user belongs to SE PM group then var enqr= (state = "Submitted")

Else if current user belongs to  SE CoE group then enqr = (state="Reviewed"). 

*Please create the encoded query from list filter.

Finally use current.addEncodedQuery(enqr);

This will give you dynamic results.

 

Hope this answers will be helpful.

Please mark the answer as helpful and correct.

Best Regards,

Rajat Choudhary

 

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

Hi @Rajat_Choudhary 

I have another before query BR that restricts SE User to view all Submission records (the code is as below):

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    if (gs.getSession().isInteractive() && gs.hasRole('x_955989_se.se_admin')) {
        current.addEncodedQuery('numberISNOTEMPTY');
    } else {
        var currentUser = gs.getUserID();

        current.addQuery('assigned_to', currentUser);
    }
})(current, previous);

The reason why I create this BR because somehow my ACL on read permission didn't work as I expected.

 

It seems that if I create a new before query BR as your suggestion, the new one wont' work with the warning message "Invalid query detected, please check logs for details [Unknown field null in table x_955989_se_submission]".

Is there any other way to solve my mentioned problem? (I'm thinking of create a Script Include, then select the link type of Module as Script and call the Script Include, but I don't know how to do this properly)

Hi @quangminh_doan ,

 

You can achieve it with script:

In script include create a function with code as below:

If current user belongs to SE PM group then var enqr= (state = "Submitted")

Else if current user belongs to  SE CoE group then enqr = (state="Reviewed"). 

 

Then create a GlideRecord query on submission table.

Use the same encoded query. 

Then push the sys_id in an array and return it.

 

This will allow you to have different set of sysId.

 

 

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

Hi @Rajat_Choudhary ,

Thanks for your advice on the script include. I have a look at the system logs and the script really returns an array of sys_id. Just another question is how to use this script include in module? I tried this syntax javascript: new myScriptIncludeName().functionName() in argument when crate module but it didn't work as I expected.