Home › Forums › SPJS-Lookup › auto populate based on lookup column
Tagged: Cascading Lookup Auto Populate
- This topic has 8 replies, 3 voices, and was last updated 2 years, 9 months ago by Alexander Bautz.
-
AuthorPosts
-
-
March 14, 2022 at 18:04 #35605
I have a change request form, when the manager selects the staff member we want to know if they are hourly or salary, which is a choice field in the parent list. How can I automatically populate a choice field in the request list with the value from the choice field in the parent list when a staff member is selected?
I think a cascading lookup would work but it requires an extra selection on the choice field in the request list which would be nice if that was auto populated, then I could do what I need, is there a way to do that?
-
March 15, 2022 at 15:10 #35608
I’m not sure I understand. Are you currently using the SPJS-lookup plugin to create a dropdown for selecting the staff member? – if so, change to use the autocomplete plugin where you can set additional fields based on the selection.
Alexander
-
March 15, 2022 at 15:48 #35606
Hi,
I’m kind of confused. You have a parent list that contains the user and if they are hourly/salary. You are creating a child. Why not have them create the child based on the user in the parent and then populate the field you want in the child like this https://spjsblog.com/vlookup-for-sharepoint/vlookup-user-manual/#Prefill_values_in_child
Cascading lookup does work also, and does not require another selection. Once you pick the first field it fills out the next one: https://spjsblog.com/dffs/dffs-plugins/spjs-cascading-dropdowns/#Set_field_value
You have another option that might work depending on your situation. You could try the autocomplete function. I don’t think it applies but it might work: https://spjsblog.com/dffs/dffs-plugins/spjs-autocomplete/#Autocomplete_in_a_text_field
-
March 15, 2022 at 20:26 #35624
Let me see if I can clarify, everything seems close but we have some complications.
Parent List – we are using FullName as the Lookup in the child list – a simple SP Lookup field. In the parent list we also have Salary vs Hourly field – choice field with Hourly and Salary as the choices.
In the child list they first select the employee from the lookup, then what I want is to auto populate a field in the child form for salary/hourly with the value.
My first attempt was a cascading lookup on the child salary/hourly field based on the parent, but then when I try and use that value with a rule it doesn’t work because when you debug it is actually returning the ID of the parent item, not the value of salary or hourly.
so if I can have a value that is set when you select an employee in the child list that I can use for rules to display hide various fields thats what I need. make sense?
-
March 15, 2022 at 21:44 #35626
Add this to your child NewForm Custom JS to set an onChange function on the lookup field that gets the value from the parent list and writes it to the child list.
jQuery("#dffs_YOUR_LOOKUP_FIELD_NAME select").on("change", function(){ var id = jQuery(this).val(); var item = spjs.utility.getItemByID({ "listName": "YOUR_PARENT_LIST_TITLE", "id": id, "viewFields":["ID", "PARENT_LIST_FIELD"] }); if(item !== null){ setFieldValue("CHILD_LIST_FIELD", item.PARENT_LIST_FIELD); } });
Change uppercases names to match your setup.
Alexander
-
March 21, 2022 at 18:14 #35638
Thank you for this help!!!! side note, I did not get any of these in email follow up even though I have it checked, I looked in spam, other and focused but nothing came from the dffs. thought you might want to know that.
-
March 21, 2022 at 20:15 #35639
I had an error in the email functionality (plugin to wordpress stopped working after an update) that I fixed on March 15. This means any notifications between February and that date may not have been sent.
Alexander
-
March 22, 2022 at 15:36 #35644
thank you sir!!!
-
March 22, 2022 at 16:53 #35645
Thanks for your donation!
Best regards,
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.