Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Function to find out whether a field is locked

Hi,

I've a requirement to find out whether a field is currently locked, in order to display a Lock / Unlock button.

Obviously I can use a variable on a toggle, but this can be foxed by a user locking or unlocking the selection themselves without using the button.

There doesn't seem to be any way using GetCurrentSelections() to discern if a field is locked or not.

Has anyone got a clever way of doing this?

Cheers,

Steve

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Is macro an option?

temp=ActiveDocument.Fields("Member").GetLocked

if temp then msgbox("Locked!")

View solution in original post

15 Replies
tresesco
MVP
MVP

Is macro an option?

temp=ActiveDocument.Fields("Member").GetLocked

if temp then msgbox("Locked!")

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

Thanks, but I'm not sure how I can apply that to a show hide criteria on a button?

Guess I would need to fire the macro on a trigger and set the value of a variable?

I'm with Henric Cronström on Macro's though - and try to avoid them at all costs.

Steve

Not applicable

Hi Steve, i have the same requirement, could you solved it?

Thanks in advanced!!

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

Hi there,

I never actually tried implementing the Macro code in the end.  The requirement went away instead.  It would appear there is no easy way of doing this - but a macro fired on change on that field to set a variable with the current lock state should work.

Good luck!

Steve

Not applicable

i'll try , Thanks!!

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

Don't you find it annoying when you are searching for a solution for something, and the only thing you can find is yourself asking the same question three years before!

Just bumping this thread up the queue, in case there is a new function in V12 that gives this.

Any suggestions?

marcus_sommer

Hi Steve,

I don't believe that there is a function which could be used for it. But maybe it could be implemented with a multi-step approach with the following logic:

- read the field-selections into a variable and prevent an update for it afterwards maybe with a second variable and if-loop

- fire a selection-action to this field with = null() which would normally clear the field unless it is locked

- compare the first variable with the current selection of this field

It's not tested just an idea but maybe it could be made workable in some way.

- Marcus

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

I thought about something like that, but this would have to fire all the time and feels like it could get a bit heavy on CPU, just to have a toggle button that goes between Locked and Unlocked.

My other thought was expanding on Treseco's variable code, having a macro that sets a variable to true or false.  This could get triggered on every selection change.  Again, I'm not sure if triggering a macro that frequently would be a good thing.

Delivered without a toggle, just a button to lock and then the unlock is done through current selections (only had the one day on site to deliver a solution).  Feels like there should be a better way though.

Great to finally meet you last week, by the way.  Hope your travels back went smoothly.

Steve

marcus_sommer

Hi Steve,

yes all the travels were quite smoothly and the weekend in Copenhaven was really great. Great too, was to meet you and all the other Luminaries there in Lund - it was very special.

Maybe there is another way to get the information if a field is locked or not. Within the xml-header of the qvw the various states of the fields are stored. This meant this information could be available while opening the qvw but I'm not sure if you could fetch any changes to them without storing the qvw again.

I don't know how qlik handled such changes to the properties - just in RAM during the run-time or puffering them into any temp-file or maybe within the prj-folder (whereby I believe they are updated through the storing, too). But maybe there are some options to them within Easter Egg ...

FieldDescription:

LOAD InternalNumber,

    Name,

    IsSystem,

    IsHidden,

    IsSemantic,

    DistinctOnly,

    Cardinal,

    TotalCount,

    PossibleCount_OBSOLETE,

    HasInfo_OBSOLETE,

    IsLocked,

    AlwaysOneSelected,

    AndMode,

    IsNumeric,

    %Key_DocumentSummary_3E3ED09C8BC69525,    // Key to parent table: DocumentSummary

    %Key_FieldDescription_8942ED1DAD568474    // Key for this table: DocumentSummary/FieldDescription

FROM [QVW.qvw] (XmlSimple, Table is [DocumentSummary/FieldDescription]);

- Marcus