populateFieldsInGrid() passing dynamic values
-
- Posts: 23
- Joined: Wed May 27, 2015
Hello,
I was trying to use this example: (https://spform.com/related-items/add-re ... point-form ) to update the a quick links field with the name opportunity but it seems it only takes static values? If I try to pass the title value which is what I need it submits an empty value.
my code example:
(Example does not work)
(Example Works)
I am probably doing something silly. Thanks for all the help again!
I was trying to use this example: (https://spform.com/related-items/add-re ... point-form ) to update the a quick links field with the name opportunity but it seems it only takes static values? If I try to pass the title value which is what I need it submits an empty value.
my code example:
(Example does not work)
Code: Select all
var title = fd.field("Title").value();
fd.populateFieldsInGrid($('.related-items'), {
Parent: '{CurrentItem}',
Oportunity: title
})
Code: Select all
fd.populateFieldsInGrid($('.related-items'), {
Parent: '{CurrentItem}',
Oportunity: 'Some random Title'
})
I am probably doing something silly. Thanks for all the help again!
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ibarrandres,
You are using a JavaScript object to populate new entries, so it also needs to be updated dynamically.
For example, like this:
You are using a JavaScript object to populate new entries, so it also needs to be updated dynamically.
For example, like this:
Code: Select all
//JS object
var populate = {
Parent: '{CurrentItem}'
};
//function to update the object
function updatePopulate(){
populate.FieldName = fd.field("Title").value();
}
//run the function when form opens
updatePopulate();
//run the function when Title is updated
fd.field("Title").change(function(){
updatePopulate();
});
//use populate object when adding new entries
fd.populateFieldsInGrid($('.related-items'), populate);
Cheers
-
- Posts: 23
- Joined: Wed May 27, 2015
Awesome! That worked. Thank you again. PS. Still looking for a beer delivery service there....
-
- Posts: 21
- Joined: Sun Feb 24, 2019
I have the same need and used the code above as my template. Can't get it to work. See code below, the item creates in the related list just no "MarkupM" value.
//JS object
var populate = {
Parent: '{CurrentItem}'
};
//function to update the object
function updatePopulate(){
populate.Markup = fd.field("MarkupM").value();
}
//run the function when form opens
updatePopulate();
//run the function when field is updated
fd.field('MarkupM').change(function(){
updatePopulate();
});
//use populate object when adding new entries
fd.populateFieldsInGrid($('.related-items'), populate);
I'm sure it's something easy, just stuck. Thank you in advance!
//JS object
var populate = {
Parent: '{CurrentItem}'
};
//function to update the object
function updatePopulate(){
populate.Markup = fd.field("MarkupM").value();
}
//run the function when form opens
updatePopulate();
//run the function when field is updated
fd.field('MarkupM').change(function(){
updatePopulate();
});
//use populate object when adding new entries
fd.populateFieldsInGrid($('.related-items'), populate);
I'm sure it's something easy, just stuck. Thank you in advance!
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Office365Guy,
This can be a lot of things, but primarily it's likely to be an incorrect Internal Field name. Please, check Internal Name of Markup and MarkupM fields, make sure you are using the correct ones in the code.
To get an Internal Name of the field go to List Settings -> select column you want to check and look at its URL:
This can be a lot of things, but primarily it's likely to be an incorrect Internal Field name. Please, check Internal Name of Markup and MarkupM fields, make sure you are using the correct ones in the code.
To get an Internal Name of the field go to List Settings -> select column you want to check and look at its URL:
Cheers
-
- Posts: 21
- Joined: Sun Feb 24, 2019
The internal field name on the related list is "Markup", the local form field name is "MarkupM". I tested the change event on the form for the "MarkupM" field using a simple alert, it returned the correct value and should have updated the JS object when it called the updatePopulate function. I used the same alert in the updatePopulate function just to verify I'm not crazy. Please correct me / my code .
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Does the Parent get populated though? Also, you are using Quick Edit mode, right?
Cheers
-
- Posts: 21
- Joined: Sun Feb 24, 2019
Yes, quick edit mode, yes it populates, just not the value for the Markup??? This is on the Edit form.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Not quite sure then... Is the field available in the selected view? Also, what's the field type that you are trying to populate?
Cheers
-
- Posts: 21
- Joined: Sun Feb 24, 2019
Got it, it was a simple field name misspelled. Took some time to find it. Thanks for the sanity check!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests