Page 1 of 1

Display Form does not display comments

Posted: 29 Mar 2017
by MFatima
Hi,

I have the following script on my display form but it is not displaying the comments as per the choices selected:

Shorter version of the query:

// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();

// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}
// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}

}

// Subscribe on status change
fd.field('Engine_x0020_Oil_x0020_Level').control().change(function () {
setComment();
});
fd.field('Fluid_x0020_Leaks').control().change(function () {
setComment();
});


// Initialize
setComment();



On new and edit forms i am using these fields and they work fine:

fd.field('Engine_x0020_Oil_x0020_Level').control().value();

I want to display the comments where the action required (0) is selected and a comment is left.

Can you please tell me why am I not seeing the comments on the display side.

Thanks,

Mariam

Re: Display Form does not display comments

Posted: 30 Mar 2017
by Dmitry Kozlov
Hi Mariam,

You do not need to use change handler in a display form, it will never be triggered. Just call setComment on form loading.
Output a and b variables to find text representation of field values:

Code: Select all

var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
alert(a);

var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
alert(b);
Then use those values in your conditions.

Re: Display Form does not display comments

Posted: 30 Mar 2017
by MFatima
Hi Dmitry,

Thanks for the reply!

Adding the alert(a); has caused the form to prompt for a message for all the fields I have in the script before it even loads the page but it is still now showing the comment when the condition is true on the display form.

Script:

// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
alert(a);
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
alert(b);


// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}

// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}


}


//Initialize
setComment()


I have attached a JPEG to explain my issue.

Thanks, Mariam

Re: Display Form does not display comments

Posted: 31 Mar 2017
by Dmitry Kozlov
What values it shows during loading the form (values of a and b)?

Re: Display Form does not display comments

Posted: 31 Mar 2017
by MFatima
Hi Dmitry,

I am attaching the screenshot to show what it prompts for when it tries to load the form.

Thanks,

Mariam

Re: Display Form does not display comments

Posted: 03 Apr 2017
by Dmitry Kozlov
OK. You should use those values in the conditions from your code, ex.:
if (a == 'Okay') {...