Skip to Content

Introduction

I would like to illustrate here how to use an iCommand Display Template to Audit the role of the User such that the command can be carried out only by the Users with the specified role.

Scenario

Certain operations like Delete/Update etc would be permitted only for certain roles of MII .

Subject knowledge
  • iCommand

  • javascript

Approach

There are 2 approaches to do this. One is using Javascript and the other is by directly setting the iCommand display template accordingly. 

Approach1:Using Javascript

Steps 

1.I am using a simple insert functionality to explain this.

On clicking the Submit Button the entered value will be inserted into the Database. This insert action is permitted only for a User with the role XMII Administrators

image

2.  The Following function is assigned to the onclick parameter of the Submit button.

         function updateaftercheck()
       {
          commandobj=document.InsertCommandAPP.getCommandObject();
          commandobj.setCommandAudit(true);
          commandobj.setCommandUser1LoginRequired(true);
          var role=”XMII Administrators”
          commandobj.setCommandRole1(role);   
            //after it is executed till here the Message Pops up
              va =T1.value
              document.InsertCommandAPP.getQueryObject().setParam(1,va );
              if(document.InsertCommandAPP.executeCommand())
                 alert(“success”);
              else
                 alert(“failure”);   
         }

         The part in bold is the code used to set the role Audit .

It makes sure that only Users with the role (in this case) “XMII Administrators” can perform the action.

3.  When you click on the Submit button the following Pop Up Message appears.

image

4.   The User has to enter his login credentials here. If it matches to the credentials of a User with role XMII Administrators in this case then the action is permitted. Otherwise the following error message is obtained.

image

Approach1:Setting Audit Directly in the iCommand

1. Open the iCommand Display template used for the action.

2.  Select the Following options in the iCommand

image

3.The action will be permitted only for Users with XMII Administrators Role .It will Pop up the same Message from the front end as shown above under the approach using Javascript.

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply