Harsha - Tuesday, August 7, 2012 1:39 AM:
Hi,
I have created one Itemtype and its form with some 'drop down','Item' and 'text' fields. Now based on the Life cycle state of my Itemtype I should disable and enable my text fields.
Like if the state is 'New' one text field should be disabled and other should be enabled.
Is it possible by creating a new java script method? or any other ways to make this happen?
Please guide me with your answers.
Thank you all,
Harsha
vasant - Wednesday, August 8, 2012 1:14 AM:
Hi Harsha,
You can write a Client Side (Javascript) method on the Form Event "OnLoad" of Form of respected Item.
Please find the sample code here...
var thisItem = document.thisItem;
var state = thisItem.getProperty("state");
if(state=="New")//if state is New then disable textbox "textbox1"
{
var textbox1 = getFieldByName("textbox1");
if (textbox1)
{
var textbox1_Style = textbox1.style;
textbox1.disabled = true;
textbox1_Style.visibility = "visible";
textbox1_Style.display = "";
}
}
Hope it helps..
Thanks & Regards,
Vasant Padhiyar
Harsha - Wednesday, August 8, 2012 2:02 AM:
Thank you Vasanth , I will try this .
Thank you
Harsha
Harsha - Wednesday, August 8, 2012 2:09 AM:
Hi Vasanth,
Thank you for responding. I tried this and able to disable the text field, but still the field allowing to enter the
text on it. In my case it should not allow to enter the text, but the field should be visible. Any way to do this?
Thank you
Harsha
Harsha - Wednesday, August 8, 2012 2:20 AM:
Hi Vasanth ,
Thank you for responding, I tried this and able to disable the field, but still it allowing to enter the text on it.
In my case the field should 't allow to enter the text, and the field should be visible. Is there any way to make this happen?
Thanks in advance,
Harsha
newcomer - Wednesday, August 8, 2012 9:08 AM:
try this(field=property name):
var field = document.fieldsTab[field].substring(0, 32);
document.getElementById(field).setAttribute("readOnly",true);
this should work for text fields... but it doesnt work for date fields.
Harsha - Thursday, August 9, 2012 4:12 AM:
Hi,
Thanks for your post, I tried that but is not working. Can you check my code and tell me where i did mistakes?
This is the code:
var thisItem = document.thisItem;
var curr_state = thisItem.getProperty("state");
var state = document.fieldsTab[state].substring(0,32);
if(curr_state=="New")
{
var correction = getFieldByName("correction");
if(correction)
{
document.getElementByName("correction").setAttribute("readOnly",true);
var correction_Style = correction.style;
correction.disabled = true;
correction.readOnly = true;
correction_Style.visibility = "visible";
correction_Style.display = "block";
}
else if(curr_state=="Submit NC" || curr_state=="In Progress")
{
correction.disabled = false;
correction_Style.visibility = "visible";
correction_Style.display = "";
}
else
{
correction.disbled = true;
correction_Style.visibility = "hidden";
correction_style.display = "";
}
}
Where 'correction' is my field name and 'state' is my property name.
Thanks in advance
Harsha
newcomer - Thursday, August 9, 2012 6:02 AM:
sry i lied. field is the name of the formelement:
So if "correction" is the name of the form element you want to disable:
var field = document.fieldsTab["correction"].substring(0, 32);
document.getElementById(field).setAttribute("readOnly",true);
Harsha - Friday, August 10, 2012 1:56 AM:
Hi, Still the result is same, The field is allowing to enter the data in disable mode . The good thing happend with your suggestion is,it not saving the entered data after saving the form. I tried my level best but not able to make the field do not allow to enter the data. The code I used is: var field = document.fieldsTab["correction"].substring(0, 32); document.getElementById('0721912612634568B60F957ED1AB56CF').setAttribute("readOnly",true); Need help. Thank you Harshanewcomer - Friday, August 10, 2012 2:17 AM:
what type of field do you use?(Item, Text, Date etc.)
Harsha - Friday, August 10, 2012 3:22 AM:
It is Text Field. In the Form I selected it as Text Area.
newcomer - Friday, August 10, 2012 3:30 AM:
For me it worked in Aras 9.3 SP2.
The user can't change the value in the text area.
Anyways, you can try this:
document.getElementById(document.fieldsTab["correction"]).disabled = true;
Harsha - Friday, August 10, 2012 3:59 AM:
Thank You , I will try this.
Can I ask you one more question? About the search criteria .