Skip to main content
frameexpert
Community Expert
Community Expert
June 14, 2016
Question

Delete an attribute from an element

  • June 14, 2016
  • 2 replies
  • 2566 views

Hi Scripters, I know from Russ Ward's samples how to delete an attribute value. But how do I delete the attribute itself from the element? The attribute is undefined in the document's EDD, that is, it shows as red in the structure view. FrameScript has a command for deleting an "undefined" attribute from an element, but I don't see a way to do this in ExtendScript. Any help will be appreciated. -Rick

I see that the FDK has an F_ApiDeleteUndefinedAttribute() function, but I don't see an equivalent in ExtendScript.

This topic has been closed for replies.

2 replies

Known Participant
July 20, 2016

I have reported a documentation bug as the doc.DeleteUndefinedAttribute has a Syntax heading but no detail in the scripting guide for 2015.

Feature#4173763 - Extendscript Doc object DeleteUndefinedAttribute has no detail in the Adobe FrameMaker Scripting Guide

Legend
July 20, 2016

Yes, just to clarify, I did not find this in the manual. The ESTK autocomplete feature showed it as an available method.

Legend
June 22, 2016

Hi Rick,

Apologies for the delay in response... I was on vacation for a while. I do see an equivalent ES method and it works OK for me, for example:

doc.DeleteUndefinedAttribute ("UndefinedAttrName", Constants.FV_Element, elem);

...where elem is the element object. Did you try this?

Russ

Known Participant
February 27, 2020

This is not working for me. More important, there is no warning or error report that says I'm doing this wrong.

I really appreciate if you could provide some guideline. Thanks!

 

I'm using FM 2017 Version: 14.0.0.361 

Both FA_errno and the return value are zero after the function call.The code is pretty simple:

#target framemaker

var flow, root;
doc = app.ActiveDoc;
flow = doc.MainFlowInDoc;
 root = flow.HighestLevelElement;
$.writeln("root="+ root.ElementDef.Name + " Attrs#=" + (root.ElementDef.GetAttributeDefs()).length);
doc.DeleteUndefinedAttribute("UndefinedAttrName", Constants.FV_Element, root);

 
 

Legend
February 28, 2020

Hi depaul, you need to put the actual attribute name in the method. For example:

 

doc.DeleteUndefinedAttribute("Id", Constants.FV_Element, root);

 

I just tested it and it works fine for me on FM2019.

Russ