Related Documents : update file custom field
-
- Posts: 23
- Joined: Wed May 27, 2015
Hello,
I would like to know if there is a way to update custom fields by using the Title input field as a dynamic value?
I am trying to use the Title form field value to update the file "Opportunity" field so that I can later use it as a filter value on my edit and display view. I saw this https://spform.com/javascript-framework ... ctionality but it doesn't talk about updating other fields besides the name(renaming).
Is there a a way I can do something like this?
I would like to know if there is a way to update custom fields by using the Title input field as a dynamic value?
I am trying to use the Title form field value to update the file "Opportunity" field so that I can later use it as a filter value on my edit and display view. I saw this https://spform.com/javascript-framework ... ctionality but it doesn't talk about updating other fields besides the name(renaming).
Is there a a way I can do something like this?
Code: Select all
var Title = fd.field("Title").value(); //get form input value
fd.updateDroppedDocuments($('.related-docs'), function(listItem) {
var result = $.Deferred();
var ctx = listItem.get_context();
var file = listItem.get_file();
ctx.load(file);
ctx.executeQueryAsync(function() {
listItem.Set_File("Opportunity", Title) //update file custom Opportunity field.
ctx.executeQueryAsync(function() {
result.resolve();
});
});
return result;
});
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ibarrandres,
Do you simply want to use Title field to update Opportunity field? This should be quite simple, you could try something like this:
Similar examples are given in the article - https://spform.com/javascript-framework ... ctionality
Do you simply want to use Title field to update Opportunity field? This should be quite simple, you could try something like this:
Code: Select all
fd.updateDroppedDocuments($('.related-docs'), function(listItem) {
var title = fd.field("Title").value();
//set the values on uploaded document:
listItem.set_item("Opportunity", title);
listItem.update();
});
Cheers
-
- Posts: 23
- Joined: Wed May 27, 2015
Hello,
Thanks for the help. I am actually trying to update the Opportunity field of the document library. My SP Form was created on a custom list and I added a related document pointing to my document library. I was able to get this working by posting via REST api then grabbing the last item ID of the document library and then updating the field with that ID via rest again. I was just thinking if there was something already built in with the js framework.
I attached an image, hopefully this helps explain better.
Thank you.
Thanks for the help. I am actually trying to update the Opportunity field of the document library. My SP Form was created on a custom list and I added a related document pointing to my document library. I was able to get this working by posting via REST api then grabbing the last item ID of the document library and then updating the field with that ID via rest again. I was just thinking if there was something already built in with the js framework.
I attached an image, hopefully this helps explain better.
Thank you.
- Attachments
-
- 2019-04-02_7-47-19.png (102.05 KiB) Viewed 2584 times
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ibarrandres,
This is exactly what the code does. You need to give Related Items CSS class: related-docs and use the code given above.
This is exactly what the code does. You need to give Related Items CSS class: related-docs and use the code given above.
Cheers
-
- Posts: 23
- Joined: Wed May 27, 2015
oh nice. Thanks for the quick reply.
I got it working but it seems it only works per single uploaded document. If you drag and drop multiple documents at once it only updates the opportunity field on one of the files.
I got it working but it seems it only works per single uploaded document. If you drag and drop multiple documents at once it only updates the opportunity field on one of the files.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ibarrandres,
That's strange, are you sure that this is the case? I've just tested the code and all items are populated at once: Are there any JS errors in the console? What version of SharePoint and Forms Designer are you running?
That's strange, are you sure that this is the case? I've just tested the code and all items are populated at once: Are there any JS errors in the console? What version of SharePoint and Forms Designer are you running?
Cheers
-
- Posts: 23
- Joined: Wed May 27, 2015
Hello,
I am on Version: 3.1.4. I noticed that sometimes it would update 2/3 documents. But never got it to update 3/3.
These are the two console errors that come up individually:
Uncaught updateDroppedDocuments failed: The file OportunitiesDocLib/1 .docx has been modified by i:0#.w|nb\User.Account on 02 Apr 2019 10:10:52 -0500.
undefined
plumsail.fd.core.js?rev=MpJY7TCL01a%2BwEFrs30OLg%3D%3DTAG0:1 Uncaught updateDroppedDocuments failed: Version conflict.
undefined
When I saw that error I thought maybe I need to turn off versioning on the document library and I did that but still getting the errors.
I am on Version: 3.1.4. I noticed that sometimes it would update 2/3 documents. But never got it to update 3/3.
These are the two console errors that come up individually:
Uncaught updateDroppedDocuments failed: The file OportunitiesDocLib/1 .docx has been modified by i:0#.w|nb\User.Account on 02 Apr 2019 10:10:52 -0500.
undefined
plumsail.fd.core.js?rev=MpJY7TCL01a%2BwEFrs30OLg%3D%3DTAG0:1 Uncaught updateDroppedDocuments failed: Version conflict.
undefined
When I saw that error I thought maybe I need to turn off versioning on the document library and I did that but still getting the errors.
Last edited by ibarrandres on 02 Apr 2019, edited 1 time in total.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ibarrandres,
The errors are likely to appear if something else is modifying the items, such as workflow. There could be a conflict, and only one change will save.
The errors are likely to appear if something else is modifying the items, such as workflow. There could be a conflict, and only one change will save.
Cheers
-
- Posts: 23
- Joined: Wed May 27, 2015
aaahh... I forgot I had a workflow running on that. That did it. Thanks a lot! Where should I send a 6 pack of beer?
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
You could send it to our office, we wouldn't mind But overall, if you enjoy using our products and they help you achieve results you are looking for, we'll be happy and continue improving, offering new solutions, features and great support (at least try to )
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 11 guests