Display Form does not display comments

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
MFatima
Posts: 13
Joined: Wed Feb 24, 2016

29 Mar 2017

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

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

30 Mar 2017

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.

MFatima
Posts: 13
Joined: Wed Feb 24, 2016

30 Mar 2017

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
Attachments
Display Form Issue.jpg
Display Form Issue.jpg (91.85 KiB) Viewed 4040 times

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

31 Mar 2017

What values it shows during loading the form (values of a and b)?

MFatima
Posts: 13
Joined: Wed Feb 24, 2016

31 Mar 2017

Hi Dmitry,

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

Thanks,

Mariam
Attachments
Prompt on Loading.jpg
Prompt on Loading.jpg (20.64 KiB) Viewed 4034 times

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

03 Apr 2017

OK. You should use those values in the conditions from your code, ex.:
if (a == 'Okay') {...

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests