else if code not executing
Hi,
I'm using the following code on my edit form, however the else if code is not working, i wonder if anything's wrong (The field QuoteRef is placed on my edit form as read only):
function setFields() {
if (fd.field('Stage').value()=='Closed Won'){
fd.field('GP').titleRequired(true);
fd.field('Title').readonly(true);
fd.field('ProjectReference').readonly(true);
fd.field('Client').readonly(true);
fd.field('LOB').readonly(true);
fd.field('Application').readonly(true);
}
else if (fd.field('Stage').value()=='Closed Lost') {
fd.field('GP').titleRequired(false);
fd.field('Title').readonly(false);
fd.field('ProjectReference').readonly(false);
fd.field('Client').readonly(false);
fd.field('LOB').readonly(false);
fd.field('Application').readonly(false);
}
else {
var quotes = fd.field('QuoteRef').control()._el().text();
fd.field('GP').titleRequired(false);
if (quotes.replace(/\s/g,"") == "") {
fd.field('Title').readonly(false);
fd.field('ProjectReference').readonly(false);
fd.field('Client').readonly(false);
fd.field('LOB').readonly(false);
fd.field('Application').readonly(false);
}
else {
fd.field('Title').readonly(true);
fd.field('ProjectReference').readonly(true);
fd.field('Client').readonly(true);
fd.field('LOB').readonly(true);
fd.field('Application').readonly(true);
}
}
}
// Calling setFields when the user changes the stage
fd.field('Stage').change(setFields);
// Calling setFields on form loading
setFields();
// Custom validation
fd.onsubmit(function () {
if (fd.field('Stage').value()=='Closed Won' && !fd.field('GP').value()){
alert('Please, fill in the GP field.');
return false;
}
return true;
});
I'm using the following code on my edit form, however the else if code is not working, i wonder if anything's wrong (The field QuoteRef is placed on my edit form as read only):
function setFields() {
if (fd.field('Stage').value()=='Closed Won'){
fd.field('GP').titleRequired(true);
fd.field('Title').readonly(true);
fd.field('ProjectReference').readonly(true);
fd.field('Client').readonly(true);
fd.field('LOB').readonly(true);
fd.field('Application').readonly(true);
}
else if (fd.field('Stage').value()=='Closed Lost') {
fd.field('GP').titleRequired(false);
fd.field('Title').readonly(false);
fd.field('ProjectReference').readonly(false);
fd.field('Client').readonly(false);
fd.field('LOB').readonly(false);
fd.field('Application').readonly(false);
}
else {
var quotes = fd.field('QuoteRef').control()._el().text();
fd.field('GP').titleRequired(false);
if (quotes.replace(/\s/g,"") == "") {
fd.field('Title').readonly(false);
fd.field('ProjectReference').readonly(false);
fd.field('Client').readonly(false);
fd.field('LOB').readonly(false);
fd.field('Application').readonly(false);
}
else {
fd.field('Title').readonly(true);
fd.field('ProjectReference').readonly(true);
fd.field('Client').readonly(true);
fd.field('LOB').readonly(true);
fd.field('Application').readonly(true);
}
}
}
// Calling setFields when the user changes the stage
fd.field('Stage').change(setFields);
// Calling setFields on form loading
setFields();
// Custom validation
fd.onsubmit(function () {
if (fd.field('Stage').value()=='Closed Won' && !fd.field('GP').value()){
alert('Please, fill in the GP field.');
return false;
}
return true;
});
What constitutes as 'not working'? Why are you retrieving QuoteRef this way? Try
In any case, use 'debugger;' with opened console (F12) to debug your code - insert
dubugger;
where you want to want the interpreter to break and then execute your code line by line to identify the source of your problem. What is titleRequired in fd.field('GP').titleRequired(false) ? Forms Designer doesn't have this function.
Code: Select all
fd.field('QuoteRef').value()
dubugger;
where you want to want the interpreter to break and then execute your code line by line to identify the source of your problem. What is titleRequired in fd.field('GP').titleRequired(false) ? Forms Designer doesn't have this function.
well for the QuoteRef field i'm using this method as i mentioned in my post i'm placing this field on my form as "Read Only", and when i tried to use the fd.field('QuoteRef').value() it didn't work out.
As for the titleRequired, actually i got it from your forum, it only places an asterisk beside a field, please refer to this link:
http://spform.com/office-365/cond ... ynamically
As for the titleRequired, actually i got it from your forum, it only places an asterisk beside a field, please refer to this link:
http://spform.com/office-365/cond ... ynamically
-
- Information
-
Who is online
Users browsing this forum: No registered users and 21 guests