Page 1 of 1
populateFieldsInGrid() passing dynamic values
Posted: 03 Apr 2019
by ibarrandres
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)
Code: Select all
var title = fd.field("Title").value();
fd.populateFieldsInGrid($('.related-items'), {
Parent: '{CurrentItem}',
Oportunity: title
})
(Example
Works)
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!
Re: populateFieldsInGrid() passing dynamic values
Posted: 03 Apr 2019
by Nikita Kurguzov
Dear ibarrandres,
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);
Re: populateFieldsInGrid() passing dynamic values
Posted: 03 Apr 2019
by ibarrandres
Awesome! That worked. Thank you again. PS. Still looking for a beer delivery service there....
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Office365Guy
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!
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Nikita Kurguzov
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:
- InternalNameColumn.png (17.04 KiB) Viewed 2827 times
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Office365Guy
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
.
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Nikita Kurguzov
Does the Parent get populated though? Also, you are using Quick Edit mode, right?
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Office365Guy
Yes, quick edit mode, yes it populates, just not the value for the Markup??? This is on the Edit form.
Re: populateFieldsInGrid() passing dynamic values
Posted: 19 Jun 2019
by Nikita Kurguzov
Not quite sure then... Is the field available in the selected view? Also, what's the field type that you are trying to populate?
Re: populateFieldsInGrid() passing dynamic values
Posted: 21 Jun 2019
by Office365Guy
Got it, it was a simple field name misspelled. Took some time to find it. Thanks for the sanity check!