Controlling the Submit Button within a UTA Level 1 Template

From SmartWiki
Revision as of 08:56, 31 July 2009 by Cameron (talk | contribs)

Jump to: navigation, search

It is sometimes necessary to control the role of the user that can submit a level 1 template by role and at the same time allow other users to save the template without being able to submit the template.

You can achieve this effect by using the following technique.

1. If present, remove @SYSTEMBUTTONS@ from the template page.

2. Insert the Javascript shown below into the template page - below the reference to the application fields (@appfields@)

You will need to modify this code to suit the particular roles that you wish to control.


@appfields@
<center>
<!-- show and hide button-->
//If Save Draft is required then add this line
<input type=submit id=savedraftbutton value='Save Draft' onClick="this.form.butaction.value=1;" class=Button>
 
<script language='javascript'>
//Control the display of the Submit and Save buttons
//Assume three roles IDS - Role1=5659, Role2=5036 and Role3=3291 - all three roles can save but only 5659 can submit
//System or UTA level roles can be used to control the display of the buttons in this case UTA roles are used
 
var m_sysaroleids="@SYSROLEIDS@"; //Initialize user system roles variable to user's system roles
var m_utaroleids="@UTAROLEIDS@"; //Initialize user UTA roles variable to user's UTA roles
var m_showsave=true; //Initialize Show Save variable to True
var m_showsubmit=false; //Initialize Show Submit varaible to False
var subpage="ex_apppage_save.jsp";  //Initialize the form action page
 
//If user in any of the three UTA roles then set Show Save variable to true
if(m_utaroleids.indexOf(',5659,')>-1||m_utaroleids.indexOf(',5036,')>-1||m_utaroleids.indexOf(',3291,')>-1)
    m_showsave=true; 
 
//if user is in the UTA role ID 5659 set Show Submit variable to true
if(m_utaroleids.indexOf(',5659,')>-1)
    m_showsubmit=true;
 
//Display the Save button is Show Save variable set to true
if(m_showsave)
   document.write("<input type=submit id=savebutton value='Save' onClick='this.form.butaction.value=0;' class=Button> ");
 
//Display the Submit button is Show Save variable set to true
if(m_showsubmit)
 document.write("<input type=submit id=submitbutton value='Submit EOI'  onClick='this.form.butaction.value=2;this.form.action=subpage' class=Button> ");
document.close();
</script>
 
<!-- End ---->

See Also