Page 1 of 1

Boolean and Multi line text

Posted: 09 Jan 2018
by andycoj
I need help with some boolean variable.
I would like to query for edit for if a boolean field is Yes or No.
If Yes, then set some fields to read only. I have done something like the following but still not working for me

var fieldName = fd.field('booleanField').value();
if (fieldName == 1){
fd.field('readOnlyField1').readonly(true);
fd.field('readOnlyField2').readonly(true);
}

The second question is I have a Enhanced rich text field that I also need to query on submit to make sure it is not empty. If the field is empty then I alert the user to make sure the field is not empty.

fd.onsubmit(function() {
var resolution = fd.field('Resolution').value();

if (resolution == '' && status == 'Completed') {
if (!fd.field(resolution).value()) {
alert('Resolution cannot be empty');
return false;
}
}

return true;
});

The resolution field is the enhanced rich text and this is not working for me.
Thanks for your help

Re: Boolean and Multi line text

Posted: 09 Jan 2018
by andycoj
i figured out the second question about resolution. I just need help with the first question about boolean. Thank you.

Re: Boolean and Multi line text

Posted: 09 Jan 2018
by andycoj
Actually I got the second one wrong as well. Now the alert is thrown when the status is even In Progress and the resolution is empty.
Any help?

Re: Boolean and Multi line text

Posted: 11 Jan 2018
by andycoj
I got the second question to work but then it stops working. Here is what I did
var status = fd.field('TaskStatus').value();

if (!fd.field('Resolution').control()._el().find('div.ms-rtestate-write').text().trim() && status = 'Completed') {
alert('Resolution is empty');
}

What am I doing wrong here? It did work and somehow it stopped working.

Thank you.

Re: Boolean and Multi line text

Posted: 11 Jan 2018
by Dmitry Kozlov
Hi!
A comparison operator is ==. So if you want to compare status variable with a value, use status == 'Completed'.

Re: Boolean and Multi line text

Posted: 11 Jan 2018
by andycoj
Sorry I had the operator correct. I miss type it in this question I asked.
Here is what I have but still not working

var status = fd.field('TaskStatus').value();
if (!fd.field('Resolution').control()._el().find('div.ms-rtestate-write').text().trim() && status == 'Completed') {
alert('Resolution field is empty');
return false;
}

Also, as part of my question can you also help with this if possible?

I need help with some boolean variable.
I would like to query for edit for if a boolean field is Yes or No.
If Yes, then set some fields to read only. I have done something like the following but still not working for me

var fieldName = fd.field('booleanField').value();
if (fieldName == 1){
fd.field('readOnlyField1').readonly(true);
fd.field('readOnlyField2').readonly(true);
}

Re: Boolean and Multi line text

Posted: 12 Jan 2018
by Dmitry Kozlov
Just try to trace field values by outputting them either into the browser console or in a message box. Here is a sample:

Code: Select all

alert(fd.field('booleanField').value())
Thus you will understand what value a field currently contains and will be able to compare it with the appropriate value.