Changes

Controlling the Submit Button within a UTA Level 1 Template

2,597 bytes added, 15:58, 3 December 2008
no edit summary
It is sometimes necessary to control the [[Role|role]] of the [[User|user]] that can [http://www.smartsimple.org/wiki/index.php/Submit_Logic submit] a [http://www.smartsimple.org/wiki/index.php/Level_1_Templates level 1 template] by [[Role|role]] and at the same time allow other [[User|users]] to save the template without being able to [http://www.smartsimple.org/wiki/index.php/Submit_Logic 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 [[Role|roles]] that you wish to control.

<pre>

@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 ---->

</pre>

[[Category:JavaScript Examples]][[Category:Universal Tracking Application]]
4,401
edits