Toggle Read-only for a SINGLE FIELD using js

Forums Dynamic Forms for SharePoint Toggle Read-only for a SINGLE FIELD using js

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Alexander Bautz 3 months, 1 week ago.

  • Author
    Posts
  • #25172

    becca
    Participant

    I’ve been switching to using js instead of rules with dffs since it just works better for me (I don’t know if it’s the level of control or if I just don’t compute rules as well as code, unfortunately I don’t have the time in my day to over-analyze so I’ll keep using it in the way that works). I’ve found the code equivalent for most of what I need from searching through here, but I can’t for the life of me find a way to toggle read-only for a single field that works. I’ve tried all possible combinations of spjs.dffs.doReadOnly([“fieldinternalname”]); and nothing has any effect. I’ve looked in every related thread and tried a plethora of possibilities and nada. I’ve tried lots of jQuery results I’ve found online too.

    Anyone have the right code?

  • #25185

    Alexander Bautz
    Keymaster

    Strange, the code you use is correct – lets say you wan to set the Title column readonly withe custom js:

    spjs.dffs.doReadOnly(["Title"]);

    How are you triggering this code? – by a button or directly on page load (on the root of the Custom JS)?

    If you load it directly on the root you might have some other rules that reverse your readonly setting.

    Alexander

  • #25189

    becca
    Participant

    I’ve been testing formatting on form load with a field that won’t be overwritten on load by any rules or code before using the correct format with a field change trigger.

    Since you brought up the trigger specifically I ran a couple more tests and found what I think is the issue;
    The field I was using to test I was using because it 1) was not required and 2) should be editable on a normal form load. After digging through my rules this seems like a similar issue to a previous post I made, things in the “then” portion of rules are interacting with other rules and code whether or not the “if” section is true. A rule that is not triggered was blocking the code, even though if it was triggered it would be doing the same thing as my code.

    Trying this format with a brand new field unreferenced in any rules and using the previous field after a trigger works perfectly. I guess I’ll be translating more of my rules into code until this bug is fixed, luckily this is pretty straight forward to do most the time.

  • #25211

    Alexander Bautz
    Keymaster

    I’m glad you found a workaround. I’m currently investigating the issues some users were having in the latest version (.65) of DFFS and have found some issues that I’m working on. Hopefully I’ll be able to get it sorted soon.

    Alexander

You must be logged in to reply to this topic.