Skip to main content
frameexpert
Community Expert
Community Expert
Jun 14, 2016 11:16 PM UTC
Question

Delete an attribute from an element

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 is closed to new replies. Start a new post to keep the conversation going.

8 replies

Known Participant
Jul 20, 2016 6:02 AM UTC

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

Translate
Legend
Jul 20, 2016 11:36 AM UTC

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

Translate
Legend
Jun 22, 2016 12:19 PM UTC

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

Translate
Known Participant
Feb 27, 2020 11:07 PM UTC

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);

 
 

Translate
Legend
Feb 28, 2020 11:05 AM UTC

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

Translate