Initial value in field
- alexey.babin
- Posts: 8
- Joined: Wed Mar 15, 2017
Hello!
I use formDesigner and I would like to set the initial value in field depending on user, who is working with form. I prepare the array
[ItemId, ItemName]
to pass it to method fd.field("FieldName").value(), and sometimes it works well, somtimes not. I understand, that this happens because lookup control rendering is asyncronous, and sometimes when I pass the array, the control is not ready.
So is there event on which I can subscribe to cath the moment when I could set the initial value?
Thanks!
I use formDesigner and I would like to set the initial value in field depending on user, who is working with form. I prepare the array
[ItemId, ItemName]
to pass it to method fd.field("FieldName").value(), and sometimes it works well, somtimes not. I understand, that this happens because lookup control rendering is asyncronous, and sometimes when I pass the array, the control is not ready.
So is there event on which I can subscribe to cath the moment when I could set the initial value?
Thanks!
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, pass the initial value to a Cross-site Lookup field in the following format and it will work even if the control is not loaded yet:
fd.field('Lookup').value('120;#Child');
Please, pass the initial value to a Cross-site Lookup field in the following format and it will work even if the control is not loaded yet:
fd.field('Lookup').value('120;#Child');
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
Hi all,
is it possible to set the initial value using variables?
ie:
fd.field('Lookup').value('varParentID;varParentTile');
I don't know the correct syntax.
My scenario is: parent form (Discussions), with a lookup and a related document.
When adding a new document from the parent form, the child form opens.
The child form has a lookup pointing to the parent (Discussions), and I need to set it with the parentID and parentTitle, to link them together.
thank you
is it possible to set the initial value using variables?
ie:
fd.field('Lookup').value('varParentID;varParentTile');
I don't know the correct syntax.
My scenario is: parent form (Discussions), with a lookup and a related document.
When adding a new document from the parent form, the child form opens.
The child form has a lookup pointing to the parent (Discussions), and I need to set it with the parentID and parentTitle, to link them together.
thank you
ciao,
Ale Stendardo
Ale Stendardo
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Alex!
If I understand correctly, you want to automatically bind newly uploaded documents added to the Related Items to the Parent form. Here you can read on how it's done - https://spform.com/documentation/related-documents This is only for documents, you can simply drag and drop them to the Related Items list.
If you want to create New Items (not documents) with Related Items and bind them to the Parent automatically, here we have an instruction on how to do it properly - https://spform.com/documentation/relate ... gular-mode This is only for items.
Please, follow every step in the instructions as all of them are very important.
If I understand correctly, you want to automatically bind newly uploaded documents added to the Related Items to the Parent form. Here you can read on how it's done - https://spform.com/documentation/related-documents This is only for documents, you can simply drag and drop them to the Related Items list.
If you want to create New Items (not documents) with Related Items and bind them to the Parent automatically, here we have an instruction on how to do it properly - https://spform.com/documentation/relate ... gular-mode This is only for items.
Please, follow every step in the instructions as all of them are very important.
Cheers
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
hi Nikita,
thank you for your prompt support.
thank you for your prompt support.
ciao,
Ale Stendardo
Ale Stendardo
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
Hi Nikita,
I followed step by step your advice, but I’m still missing something and hope you can help.
This is my scenario:
I have a parent list “Discussion_parent” where I add documents with the Related Items.
When clicking on “New Document”, I select a document, then the Child Form “Documents_child” opens, but the lookup “Discussions” that is linked to the field “Subject” in the parent, is empty.
I could select from the “Discussions” dropdown the correct value, but I need that this is automatically set to the parent value, to make sure it’s alway correctly linked to it.
That’s why I was looking to set field “Discussions” on form load, retrieving parent form values (i.e. fd.field('Lookup').value('120;#Child'); ).
The lookup “Discussions” has ID and Subject columns.
Hope this have sense for you.
I followed step by step your advice, but I’m still missing something and hope you can help.
This is my scenario:
I have a parent list “Discussion_parent” where I add documents with the Related Items.
When clicking on “New Document”, I select a document, then the Child Form “Documents_child” opens, but the lookup “Discussions” that is linked to the field “Subject” in the parent, is empty.
I could select from the “Discussions” dropdown the correct value, but I need that this is automatically set to the parent value, to make sure it’s alway correctly linked to it.
That’s why I was looking to set field “Discussions” on form load, retrieving parent form values (i.e. fd.field('Lookup').value('120;#Child'); ).
The lookup “Discussions” has ID and Subject columns.
Hope this have sense for you.
ciao,
Ale Stendardo
Ale Stendardo
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Alex!
Which of the two instructions are you referring to? Related Documents or Related Items Regular Mode?
As far as I understand, you have Discussions list, where you added Related Items field to the forms, you try to add new documents there and they are not being linked. Does it happen with both New Form and Edit Form or only with one of them? What about your Documents - is it a List or a Document Library?
Just add some screenshots of the forms, so we can take a closer look at them and determine what exactly needs fixing.
One last thing, if you experience troubles with the edit form, please replace:
with
We've updated the instruction, this line was causing a bug to appear in certain circumstances.
Which of the two instructions are you referring to? Related Documents or Related Items Regular Mode?
As far as I understand, you have Discussions list, where you added Related Items field to the forms, you try to add new documents there and they are not being linked. Does it happen with both New Form and Edit Form or only with one of them? What about your Documents - is it a List or a Document Library?
Just add some screenshots of the forms, so we can take a closer look at them and determine what exactly needs fixing.
One last thing, if you experience troubles with the edit form, please replace:
Code: Select all
var parentId = window.top.GetUrlKeyValue('ID');
Code: Select all
var parentId = parseInt(window.top.GetUrlKeyValue('ID'));
Cheers
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
I have added a screenshot and I'm going to review all the code.
thank you
ciao,
Ale Stendardo
Ale Stendardo
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
What about using Drag and Drop feature? If you set up everything according to this instruction, it should work -
https://spform.com/documentation/related-documents
Just change the code to your field name:
You can also write additional code to fill in the rest of the fields. But you won't be able to click "New Document", instead you will just drop documents into the list.
https://spform.com/documentation/related-documents
Just change the code to your field name:
Code: Select all
fd.updateDroppedDocuments($('.related-docs'), {
Discussioni: '{CurrentItem}'
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest