Hi i have created a number of dropdown's and text boxes for personal information. On the page code the fields have been assigned to either null or undefined depending upon user flow / choice
My current js has me by the balls at the moment. Any changes i make means that i cannot open a collection as this shows internet error which isn't true. I have saved from a previous version and experimented to prove this.
I think this is because i have saved a previous version that now isn't fit for purpose.
What i'm trying to achieve is based on the following but has these field keys
nickName, prefix, subPrefix, addOwnPrefix, firstName, middleName, lastName, suffix, addYourownSuffix
on the page code for any fields that will be empty i have assigned null or undefined,
so this is what i have, do i need to create a new js file to stop the collection being corrupted.
I took this code from a forum post and am unsure if the items should also concertina, a correct code example would be great
export function Member_afterQuery(item, context) {
item.fullName = item.nickName + "" + item.subPrefix + "" + item.firstName + "" + item.middleName + "" + item.lastName + "" + item.suffix;
let fullName = '';
if (item.nickName !== undefined) {
fullName = item.nickName.trim() + ' ' + item.subPrefix;
} else {
fullName = item.subPrefix;
}
if (item.subPrefix !== undefined) {
fullName = item.subPrefix.trim() + ' ' + item.firstName.trim();
} else {
fullName = item.firstName;
}
if (item.middleName !== undefined) {
fullName = fullName + ' ' + item.middleName.trim() + ' ' + item.lastName.trim();
} else {
fullName = fullName + ' ' + item.lastName;
}
if (item.suffix !== null) {
fullName = fullName + ' ' + item.suffix;
}
item.fullName = fullName;
return item;
}
Thanks
Adam
It's the commas. There should be none.
I have added this code and can't understand why middleName and lastName fields are not being picked up and displayed
export function MemberCandles_afterQuery(item, context) {
item.fullDobdod = item.dob + " " + item.dod;
let fullName = "";
if (item.prefix) {
}
if (item.subPrefix) {
}
if (item.addOwnPrefix) {
}
if (item.firstName){
}
if (item.middleName){
}
if (item.lastName){
}
fullName = item.prefix + " " + item.subPrefix + " " + item.addOwnPrefix + " " + item.firstName, + " " + item.middleName, + " " + item.middleName, + " " + item.lastName;
return item;
}
ok so i'm still at a loose end with this. Just want to put a fullName string together from a js file and leave out any fields that do not have a value
so as background example i have two cascading dropdown's in page code and if user reaches the second dropdown i have assigned the first one to have a value of null
this also applies to other fields based on above logic. well i hope its logical :)
I do now :) thanks so i think i'll be able to have a play around tomorrow and use a similar code but without trim for each field key
so can for each field key can i write code to define each key as either, null, undefined or 'value present' to create this fullName string
and if so was that the right code that i added
Thanks
Adam