Forum Replies Created
-
AuthorPosts
-
September 22, 2021 at 22:25 in reply to: Misc Tab not listing Fields under Hidden fields section #34551
That was it. Once I hit save on the config for each form type the field list appeared. Thanks.
Worked perfectly, thanks.
Ok, I think this works.
function openInWeb(val, item) { var name = item.get_item("FileLeafRef"); var url = item.get_item("FileRef"); return "<a href='" + url + "?web=1' target='_blank'>" + name + "</a>"; } function openInDesktopApp(val, item){ //debugger; var retlink = ""; var name = item.get_item("FileLeafRef"); var doctype = name.substring(name.lastIndexOf('.') + 1).toLowerCase(); var url = makeAbsUrl(item.get_item("FileDirRef") + "/" + name); switch(doctype) { case "doc" : case "docx" : retlink = "<a href='ms-word:ofe|u|" + url + "'>" + name + "</a>"; break; case "xls" : case "xlsx" : retlink = "<a href='ms-excel:ofe|u|" + url + "'>" + name + "</a>"; break; default: retlink = openInWeb(val, item); break; } return retlink; }
- This reply was modified 3 years, 8 months ago by Brian Oster.
- This reply was modified 3 years, 8 months ago by Brian Oster.
- This reply was modified 3 years, 8 months ago by Brian Oster.
I was having the same issue as Paul in that I need to be able to click the link and edit the document and save changes back to the document in the list. The openInWeb function worked great for this.
However, is there a way to have it open in the Office Desktop App instead of the Web. I am not talking about the default behavior which is to download the document and then effectively edit it locally. I want the default behavior when viewing in native SP where you have the option to “Open in Word” or “Open in Excel” so that edits are saved back to the document in the doc lib. This way I can give users effectively the same option as “Open in Excel” or “Open in Excel Online”.
June 3, 2021 at 15:22 in reply to: Create New Document in directly in Library instead of just upload existing #33699Never mind. Finally got it all working. Your example code from Post 29668 was all good. I had the Document Library GUID wrong.
June 3, 2021 at 15:04 in reply to: Create New Document in directly in Library instead of just upload existing #33697After debugging I found the initial problem. It appears it is not finding the inserted document object. The line “if(res.count > 0)” fails so it never trys to set the document properties. So spjs.utility.queryItems appears to not find the document.
var res = spjs.utility.queryItems({ "listName": targetLibGUID, "query": "<Where><Eq><FieldRef Name='FileLeafRef' /><Value Type='Text'>" + newDocName + "</Value></Eq></Where>", "viewFields": ["ID", "EncodedAbsUrl"] }); debugger; if (res.count > 0) { var item = res.items[0]; var uRes = spjs.utility.updateItem({ "listName": targetLibGUID, "id": item.ID, "data": { "Project_x0020_ID": projectID, "Category": "Special Instructions" } }); if (uRes.success) { // Refresh vLookup table jQuery("#vLookupManualRefresh_" + vLookupFieldname).trigger("click"); var a = document.createElement("a"); a.setAttribute("href", "ms-word:ofe|u|" + item.EncodedAbsUrl); a.setAttribute("target", "_blank"); document.getElementsByTagName("body")[0].appendChild(a); a.click(); } }
June 2, 2021 at 21:55 in reply to: Create New Document in directly in Library instead of just upload existing #33693So very close. I have it creating documents from my Templates Doc Lib and inserting into the target Doc Lib but I can’t
a) get it to link to the parent
b) set additional propertiesHere is the relevant section of js:
` if (res.count > 0)
{
var item = res.items[0];
var uRes = spjs.utility.updateItem(
{
“listName”: targetLibGUID,
“id”: item.ID,
“data”:
{
“Project_x0020_ID”: getFieldValue(“ID”),
“Category”: “Special Instructions”
}
});See attachment for vLookup Query Definition. I even tried hard coding the Project ID value just to see if it would work and it still would not set that property.
- This reply was modified 3 years, 8 months ago by Brian Oster.
Attachments:
June 1, 2021 at 20:32 in reply to: Create New Document in directly in Library instead of just upload existing #33686I may have found another thread that may do what I want.
-
AuthorPosts