0 votes


I'm trying to do activating/deactivating a category depending if a specific value is chosen on lookup field.

first I added onchange event to lookup field to check if the a certain value is chosen then i'm activating a category, but if this value is changed to another one, then how can I deactivate the category in the edit context (this is before applying or saving the record because user needs to fill in data in the category if the certain value is chosen)

Thanks in advance for your advise and help.

Best Regards.

asked in Efficy/ Client side by (559 points)

3 Answers

+1 vote
Best answer


This is documented in the Cookbook (Document reference=DOC-KPA-2015/10-005307)

Search for the topic, "How to build a "Activate Category button" without losing context state". It's a 2012 recipe, but the architecture is the same for Efficy 10, except the old styled event binding using onclick. Better is to use addEventListener, or data-msg.

To deactivate a category, use this design pattern:

var dsCatg = Database.getCategoryDataSet(editHandle, mycategory);
answered by (7.4k points)
selected by
Hello Kristof,

Thank you for this reference, it's useful. But the issue I'm facing currently is in deactivating the category, how to disable it if we click a button or choose an option in lookup. is it possible to deactivate category in some serverscript script?

Thank you for advise and help.

Best Regards.
i'll update my original answer
Hello Kristof,

It works perfectly :), thank you for your help and advise.

Best regards.
0 votes


In my opinion, you should just hide / display the "always activated category". this way you will be able to change the screen behaviour without saving or applying changes.

Then, add a workflow function that will empty your category fields if the "desactivation" values are selected (if needed).

this will not avoid a html injection hack, but It s probably not an issue.

answered by (989 points)
0 votes

Hello Louis,

Thank you for the advise, but actually i was searching for more reliable solution and found that there's functionality used on "Category" choosing window called "AddRelation" which is basically the function being called when you click ok in category choosing popup. I've tried to simulate this in this code in MacroEditSCustom.txt where 80156 is the category ID:

JsScriptsTRW.Case {[

    function AfterLoaded() {

    function ActivateRelatedCategory(){
        var caseType = $("#CASETYPE").val();
            window.EntityModified = false;
        if(parseInt(caseType) == 5)


when choosing the value to 5 it works perfectly, but when i change it to another one it gives an error like this:
enter image description here

Any Advise or help please?

Thank you.
Best Regards.

answered by (559 points)
1,249 questions
1,519 answers
328 users