Thursday, 19 September 2019

Sharepoint upload file increase and Links

Error:

The request message is too big. The server does not allow messages larger than 2097152 bytes

Solution:

Run script  in Sharepoint Power Shell :
$ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$ws.ClientRequestServiceSettings.MaxReceivedMessageSize = 20242880
$ws.ClientRequestServiceSettings.MaxParseMessageSize  = 20242880
$ws.Update()

====================
     string documentBody1 = _itemAttachment.Attributes["body"].ToString();
var aaa=new  MemoryStream(Convert.FromBase64String(documentBody1));

   public static void UploadFileToSP(ClientContext ctx, string listName, string fullUrlWithFileName, byte[] content,MemoryStream aaa)
        {
            //  Send the file content to SP
            Microsoft.SharePoint.Client.List list = ctx.Web.Lists.GetByTitle(listName);
            FileCreationInformation file1 = new FileCreationInformation();
            file1.Overwrite = true;
            file1.Url = fullUrlWithFileName;// "/demo/email/57FD46F959DBE81180C200155D668D45_testfilename";// fullUrlWithFileName;
                                            // file1.Content = content;
            file1.ContentStream = aaa;
            Microsoft.SharePoint.Client.File uploadFile = list.RootFolder.Files.Add(file1);
            //list.con
            ctx.Load(uploadFile);
            ctx.ExecuteQuery();
        }
=========================

Sharepoint 'Sync Now' functionality and share files on network drive

https://bitwizards.com/thought-leadership/blog/2015/december-2015/how-to-map-sharepoint-document-libraries-as-networ

https://support.office.com/en-us/article/sync-sharepoint-files-with-the-onedrive-for-business-sync-client-groove-exe-59b1de2b-519e-4d3a-8f45-51647cf291cd


Sharepoint upload solution in SP:
https://sharepoint.stackexchange.com/questions/189704/how-to-upload-a-sharepoint-site-template-wsp-when-the-solution-link-is-missin

https://www.c-sharpcorner.com/UploadFile/93cb27/deploying-the-solution-in-sharepoint-online/

Powershell Script:
Power shell Script

./AllowHtcExtn.ps1 https://mysharepointserver/CRM 




SharePoint Online

FileCreationInformation.Content=Convert.FromBase64String(fileData);
//fileData being the document body of my attachment.

Instead of using the Content method of FileCreationInformation, I used ContentStream as below:

FileCreationInformation.Content=new MemoryStream(Convert.FromBase64String(fileData));



Wednesday, 18 September 2019

MSCRM Disable Fields in Business Process Flow

Add the prefix 'header_process_' of the field schema name 'new_testfield' and use the below script for disabling the field using javascript:

Xrm.Page.getControl('header_process_new_testfield').setDisabled(true);



Thanks
Narendra

Sunday, 15 September 2019

MSCRM 365 v9 bind subgrid using fetch XML by javascript

function QuoteLinesFromQuote(executionContext) { 
    var formContext = executionContext.getFormContext();
    //Show the section on function call.
Xrm.Page.ui.controls.get('Quotelines').setVisible(true);
    // Xrm.Page.ui.tabs.get("tab_Quotes").sections.get("CONTACT_PREFERENCES").setVisible(true);
    // Quotelines : is name of subgrid given on Form. 
    var objSubGrid = window.parent.document.getElementById("Quotelines");
    var globalContext = Xrm.Utility.getGlobalContext();
    var version = globalContext.getVersion();
    // You need the timeout for at least the form is properly loaded.
    var subRowCount = 1;
    if (subRowCount == 0) {
        setTimeout(QuoteLinesFromQuote(executionContext), 5000);
    } else {
        // When subgrid is loaded, get the other relevant value.
        var QuoteIDValue = formContext.data.entity.getId();
        //Create FetchXML for sub grid to filter records
        var FetchXml = '<fetch version = "1.0" output-format="xml-platform" mapping = "logical" distinct = "false" > ' +
            '<entity name="quotedetail">' +
            '<attribute name="productid" />' +
            '<attribute name="productdescription" />' +
            '<attribute name="priceperunit" />' +
            '<attribute name="quantity" />' +
            '<attribute name="extendedamount" />' +
            '<attribute name="quotedetailid" />' +
            '<order attribute="productid" descending="false" />' +
            '<filter type="and">' +
            '<condition attribute="quoteid" operator="eq" uitype="quote" value="{' + QuoteIDValue + '}" />' +
            '</filter>' +
            '</entity>' +
            '</fetch>';

        // Layout of subgrid.
        //var LayoutXml = "<grid name='resultset' object='8' jump='new_name' select='1' preview='1' icon='1'>" +
        //    " <row name='result' id='new_boat'>" +
        //    "<cell name='productid' width='100' />" +
        //    "<cell name='productdescription' width='200' />" +
        //    "<cell name='priceperunit' width='100' />" +
        //    "<cell name='quantity' width='200' />" +
        //    "<cell name='quotedetailid' width='200' />" +
        //    "</row>" +
        //    "</grid>";
        // Apply layout and filtered fetchXML
        //objSubGrid.control.SetParameter("layoutXml", LayoutXml);
        objSubGrid.control.SetParameter("fetchXml", FetchXml);
        //Refresh grid to show filtered records only.
        objSubGrid.control.Refresh();
    }
}