Boolean and Multi line text

Discussions about Forms Designer for SharePoint 2010.
Locked
andycoj
Posts: 6
Joined: Wed Aug 09, 2017

09 Jan 2018

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

andycoj
Posts: 6
Joined: Wed Aug 09, 2017

09 Jan 2018

i figured out the second question about resolution. I just need help with the first question about boolean. Thank you.

andycoj
Posts: 6
Joined: Wed Aug 09, 2017

09 Jan 2018

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?

andycoj
Posts: 6
Joined: Wed Aug 09, 2017

11 Jan 2018

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

11 Jan 2018

Hi!
A comparison operator is ==. So if you want to compare status variable with a value, use status == 'Completed'.

andycoj
Posts: 6
Joined: Wed Aug 09, 2017

11 Jan 2018

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);
}

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

12 Jan 2018

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.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest