none
Can i prevent Grid Editting for a field inside modern UI RRS feed

  • Question

  • I have created a site column of type Single link of text, and i hide it from the New & Edit forms using this PnP script:-

    $customfield.SetShowInEditForm($false)
    $Context.ExecuteQuery()
    $customfield.SetShowInNewForm($false)
    $Context.ExecuteQuery()
    $customfield.UpdateAndPushChanges($false)
    $Context.ExecuteQuery()

    but still the field will be editable when using the list's Quick Edit. Now in the classic UI, i use to create JSLINK and link it with the field which will cause the filed to be in Read-Only inside the quick edit grid. here is the JSLINK i use to have:-

    (function () {
        var overrideContext = {};
        overrideContext.Templates = overrideContext.Templates || {};
        overrideContext.Templates.OnPreRender = function(ctx) {
            var statusField = ctx.ListSchema.Field.filter(function(f) {
                return f.Name === 'ItemNumber';
            });
            if (statusField.length>0) {
                statusField[0].AllowGridEditing = false;
            }
        }
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
    })();

    but seems this approach will not work inside the modern UI. so can anyone advice on this? Can I take benefit from the column formatting capability?


    • Edited by johnjohn11 Thursday, October 17, 2019 7:55 AM
    Thursday, October 17, 2019 7:55 AM

All replies

  • Hi John,

    Json Column Formatting not provide option to disable editing of a field in Quick Editor View.

    If you don't want a field to update both in edit form and Quick Editor View, set field to Read-Only directly using the PnP PowerShell:

    Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/dev -Credentials Get-Credential
    $listTitle="myList9"
    $fieldName="Title"
    $customfield=Get-PnPField -List $listTitle -Identity $fieldName
    $customfield.ReadOnlyField = $true
    $customfield.SetShowInEditForm($false)
    $customfield.SetShowInNewForm($false)
    $customfield.UpdateAndPushChanges($false)
    $customfield.Context.ExecuteQuery()

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, October 18, 2019 6:38 AM
  • Hi John,

    Json Column Formatting not provide option to disable editing of a field in Quick Editor View.

    If you don't want a field to update both in edit form and Quick Editor View, set field to Read-Only directly using the PnP PowerShell:

    Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/dev -Credentials Get-Credential
    $listTitle="myList9"
    $fieldName="Title"
    $customfield=Get-PnPField -List $listTitle -Identity $fieldName
    $customfield.ReadOnlyField = $true
    $customfield.SetShowInEditForm($false)
    $customfield.SetShowInNewForm($false)
    $customfield.UpdateAndPushChanges($false)
    $customfield.Context.ExecuteQuery()


    ok thanks for your helpful reply. but if i set a field as read only can i update its value inside a workflow? as in my case i am populating this column value inside workflow 2013, using the Update list item action as follow:-

    Thanks

    Friday, October 18, 2019 12:48 PM
  • Hi John,

    Json Column Formatting not provide option to disable editing of a field in Quick Editor View.

    If you don't want a field to update both in edit form and Quick Editor View, set field to Read-Only directly using the PnP PowerShell:

    Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/dev -Credentials Get-Credential
    $listTitle="myList9"
    $fieldName="Title"
    $customfield=Get-PnPField -List $listTitle -Identity $fieldName
    $customfield.ReadOnlyField = $true
    $customfield.SetShowInEditForm($false)
    $customfield.SetShowInNewForm($false)
    $customfield.UpdateAndPushChanges($false)
    $customfield.Context.ExecuteQuery()


    ok thanks for your helpful reply. but if i set a field as read only can i update its value inside a workflow? as in my case i am populating this column value inside workflow 2013, using the Update list item action as follow:-

    Thanks

    Hi John,

    Setting read-only will also apply for workflow update.

    As currently, No front-end code will prevent update in Quick Edit View for Modern UI, I suggest you could still use classic experience. Or you could create a view specially for Quick Edit which will hide the column so it won't appear to update.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, October 21, 2019 8:35 AM