AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 09.05.2023, 07:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
How to create a new folder on Sharepoint
Источник: http://alexvoy.blogspot.com/2023/05/...harepoint.html
==============

There are some useful code behind OfficeSharePointFolderSelectionDiaolog form; however, there is a limitation.




Well, we can create a new folder via REST API call as follows. Take note that the access token is created in testSharePointConnection

using Microsoft.Dynamics.Platform.Integration.SharePoint;using System.Net;using System.Net.Http;[Form]public class wzhSPFolderForm extends FormRun{ str apiUrl; System.Exception ex; ISharePointProxy proxy; public void init() { super(); fNewFolder.text('_wzhNewFolder'); fServer.text('https://wzhServer.sharepoint.com'); fRootFolder.text('Shared Documents'); } public boolean testSharePointConnection() { str src = fServer.text(); boolean validConnection = false; if(src) { System.UriBuilder builder = new System.UriBuilder(src); str hostName = builder.Host; str siteName = fRootFolder.text(); str externalId = xUserInfo::getExternalId(); proxy = SharePointHelper::CreateProxy(hostName, '/', externalId); if(proxy) { if(SharePointHelper::VerifyAuthentication(proxy)) { validConnection = true; info(strfmt('@ApplicationFoundation:SPServerCommunicationSuccess', hostName)); } else { info(strfmt('@ApplicationFoundation:SPServerUserNotAuthorized', hostName)); } } else { info(strfmt('@ApplicationFoundation:SPSelectionDlg_ErrorNoProxy', hostName)); } } return validConnection; } public str GetAuthorizationToken() { return proxy.AccessToken; } public void createSPFolder() { apiUrl = strFmt("%1/_api/web/lists/getbytitle('%2')/rootfolder/folders/add('%3')", fServer.text(), fRootFolder.text(), fNewFolder.text()); try { if(this.testSharePointConnection()) { str token = this.GetAuthorizationToken(); System.Net.WebHeaderCollection httpHeader = new System.Net.WebHeaderCollection(); httpHeader.Add("Authorization", 'Bearer ' + token); HttpWebRequest request = System.Net.WebRequest::Create(apiUrl); request.set_Headers(httpHeader); request.set_ContentLength(0); request.set_Method("POST"); request.set_ContentType("application/json;odata=verbose"); System.Net.HttpWebResponse response = request.GetResponse(); int statusCode = response.get_StatusCode(); info(strFmt("HTTP status code: %1", statusCode)); } } catch { //exception ex = CLRInterop::getLastException().GetBaseException(); error(ex.get_Message()); } } [Control("Button")] class bCreateREST { /// /// /// public void clicked() { element.createSPFolder(); super(); } } [Control("Button")] class bTestConnection { /// /// /// public void clicked() { element.testSharePointConnection(); super(); } }}




Источник: http://alexvoy.blogspot.com/2023/05/...harepoint.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
saurav-nav: NAV 2018 - Lots of New Objects! Blog bot NAV: Blogs 0 04.12.2017 10:11
Gareth Tucker: Enabling SharePoint Integration on a CRM Online Trial Blog bot Dynamics CRM: Blogs 0 21.07.2014 04:43
atinkerersnotebook: Creating Your Own Document Management System With SharePoint Blog bot DAX Blogs 0 02.10.2013 21:12
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
Dynamics CRM Tools: How to create a relative URL in site map to static content under the ISV folder in CRM 4 Blog bot Dynamics CRM: Blogs 0 22.03.2010 16:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 18:51.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.