1

I have updated the logic to clear the field during display start event. Note: Updated my logic in readonly.js GUI extension

if($display)
{
   $evt.addEventHandler($display,start,ResetMetadataField)
}
Function ResetMetadataField()
{
  //code goes here
   var fieldBuilder = view.properties.fieldBuilder;
   var metadataTab = GetMetadataTab()
   if(metadataTab)
   {
     var fieldbuilder = GetMetadataFieldBuilder();
    //logic goes here to reset the metadata field
   }
}

But this code triggers during Save event as well. I need to reset the field only when component is re-opened but not on Save.

I am unable to differentiate between item re-open and other events like save,check-in..etc Is there a way to achieve the functionality?

1
  • What are the conditions under which $display is set to true. Is it reset to false before the onSave event is triggered! Have you tried/checked different events to trigger your code off rather than just a parameter? Commented Apr 10, 2022 at 8:55

1 Answer 1

2

Checkout the event system subscription. You probably need to subscribe to a specific event and not just run code according to a preset parameter.

This may well help as a starter: http://www.tridiondeveloper.com/intro-to-the-event-system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.