I have vlookup on the parent that users fill in some child docs on a 2nd list.
Is there a way I could feed the totals (as highlighted) into 3 fields on Parent list on saving the parent doc ?
I would like to do this when the user creates or edits the vlookup from the parent form dialog.
Yeah I figured it was probably not worth the effort. Thanks for the input and info.
Apologies, I’m hoping this is my last question, and I may be overlooking/overthinking it but is there a way to pass field values on the parent form (edit form) to a new/edit child form? Reason being that I have a child list containing an autocomplete that needs to filter from the autogenerated ID of the parent.
The problem is that the Title field is required – and the built in validation of all required fields are performed before the dffs_PreSaveAction function is triggered. When a field is empty, the function will never be triggered.
This means you must either remove the required flag on the title field in your list settings, or you must add a dummy / placeholder value to the Title field on form load – something like this:
setFieldValue("Title", "...");
Alexander
Hello there!
I was added one new html input in my DFFS form header and i want to use this input box for Title(require column) of List.
I was put this Input box in header section because i want to put this at very top along with some design and background.
Now, I want to validate this input box when user click on save button, I was simply hided Title fields that i was add through form.
So, how can i validate this input box on save, also how can i remove error message?
Code on header:
<input type=”text” id=”newProjectTtl”></input>
I have a main request list and 2 vlookup fields (1 list; 1 doc lib). I want to give the user the ability to Edit their results either within the main request list (via vLookup) OR directly in one of the vLookup lists (not ever navigating to the request list) and when they hit save it redirects them to their parent in Edit form.
When I use spjs.dffs.redirect it works if updating directly from the child lists. But if I update via the main request list it still triggers the redirect which I don’t want.
Is there anyway to toggle the redirect logic on save, dependent on how the user is accessing the data – directly from the child list vs from the vLookup edit?
I love this and this is exactly what I’m looking for. 2 questions:
If I’m keeping my edit/display form and new form JS logic together how can I create a global variable that let’s me know which form the current user opened (dialog or not)? That way I could set another variable to equal getFieldValue(“_vlookupID”) for New and spjs.dffs.data.thisItemID for Edit/Display?
If I have 2 vlookups – 1 child is a doc library the other is a list. Is it better to create one function/section to handle both break out into two different loops?
Hi Alexander,
I am trying to get this to work a few years later but guess things have changed.
Instead of linking to “vLookup_ListView.html” in the SPJS/CEWP folder of DFFS, do I now add a CEWP to the form and point it to /SPJS/DFFS/CEWP/DFFS_frontend_CEWP.html?
Having trouble showing the child items in the Parent List view.
It is a classic list, I have added the vlookup column, and tabular view is checked.
Basically just want a link to the child item from the parent item.
Add this snippet to your NewForm Custom JS:
function dffs_PreSaveAction() {
var searchVal = getFieldValue("Title"); // Change field name to match your field here and in the query below
var res = spjs.utility.queryItems({
"listName": _spPageContextInfo.pageListId,
"query": "<Where><And><Eq><FieldRef Name='Author' LookupId='TRUE' /><Value Type='Integer'>" + _spPageContextInfo.userId + "</Value></Eq><Eq><FieldRef Name='Title' /><Value Type='Text'>" + searchVal + "</Value></Eq></And></Where>",
"viewFields": ["ID"]
});
if (res.items.length === -1) {
spjs.dffs.alert({
"title": "Error in query",
"msg": res.errorText
});
return false;
} else {
if (res.items.length > 0) {
spjs.dffs.alert({
"title": "Duplicate entry",
"msg": "You already have one record with the value \"" + searchVal + "\" in this list."
});
return false;
}
}
return true;
}
This example uses the Title field value as “primary key” so you must change it to whatever field you find the value in.
If your “primary key” is based on more than one field you must change the searchVal variable and the query to match.
Let me know if you have any questions.
Alexander
The “connection” between parent and child in vLookup is based on a matching value in the two lists – this being the ID of the parent found in a lookup field in the child, or a _vLookupID in a single line of text field being found in a _vLookupParentID field in the child. This means your child items need to have a value matching the parent item to make this connection.
I’m not sure I understand what you mean by “However, the Child to Parent lookup field connection discussed here won’t work for some of the associated fields I need to pull from the Parent into the Child record as these Parent fields are multi-line or choice field formats.” – if you want to auto-fill a multichoice value from the parent down to each child after setting up this connection as described above you will have to write a custom script to do that.
Alternatively you can set up a new reverse vLookup field connection from the child to the parent to show data from the parent in each child, but don’t allow adding new “parents” as this will not make sense.
Let me know if you have any questions.
Alexander
Hello guys,
Here is my problem:
1. I have a cascading dropdown and based on the field “Kod”, the other field are available.
2. I have a source list where the “Kod” is for example “123”. If I click “New Item” in the current list where cascading dropdown is set – I choose 123 from a field, another dropdown column appears with the products.
2.1. Source list contains columns “Kod” and “Products” and it looks like this:
- 123
Apples
- 123
Pears
- 123
Bananas
For one “Kod” can be linked with several “Products” – up to 25 or more.
3. If someone chooses “123” and select “Apples” then rates its quality, taste,… – standard rating form. If he saves the list item under “Kod” = 123 and “Products” = Apples he should not rate this article again.
Every time someone wants to rate the product he needs to save a new list item.
Is there a way how to hide it from the user?
Thank you for some hints.
Steo
-
This topic was modified 3 years, 11 months ago by
Steve.
-
This topic was modified 3 years, 11 months ago by
Steve.
Alexander,
I have a similar requirement as above. I need to preload 5000 Child items in a new list and have each Child auto connect to the corresponding Parent in an existing Parent list (one or more children connect to a single parent). However, the Child to Parent lookup field connection discussed here won’t work for some of the associated fields I need to pull from the Parent into the Child record as these Parent fields are multi-line or choice field formats.
After this backfill operation is complete Child records will be added in a normal fashion from the Parent form.
Thanks for your help,
MikeS
Hi,
The reason it does not work in a list view is because the custom js you have added in the form does not load in a list view. You can try to add a script editor web part in the list view to include the relevant custom js there (wrapped in a script tag).
Alexander
I have noticed that the ‘Delete’ word does not appear in my ListViews, only on the forms where I am showing the child records. Is there something else I have to do to have the delete functionality in a listview?
When your REST call returns the value you want to fill in a field you use this function to set it:
setFieldValue("The_field_internal_name_of_your_field", the_value_from_your_rest_call);
Sending data to another list on save can be done by adding the HTML in a HTML section in your form, and then add this code to your Custom JS:
// Keep track of the custom function being completed
var hasSubmittedCustomHTML = false;
// Used to ensure the custom HTML is not saved multiple times if save is not hit multiple times
var isSavingCustomHTML = false;
function doSaveCustomHTML(){
// Add your custom REST call here and add the two below rows in the success/done callback from your REST call
hasSubmittedCustomHTML = true;
spjs.dffs.triggerSave();
}
function dffs_PreSaveAction() {
if(!hasSubmittedCustomHTML){
if(!isSavingCustomHTML){
isSavingCustomHTML = true;
// run your custom REST function to update another list
doSaveCustomHTML();
}
return false; // Return false to wait for the custom function to finish
}else{
// Custom HTML submitted - save item
return true; // Continue saving item
}
}
Please note that the actual HTML and the custom REST API call to save the custom HTML is not included here.
Alexander
I have come across scenario where i need to bind some fields when new form will be open, value should be come from another list, i will use rest api call to get data from other list, but how can i bind data into field before form will be load?
same, i will create some html input fields and want to store those field data into other SharePoint list on submit button, how can i achieve this?
Thanks