Skip to main content
frameexpert
Community Expert
Community Expert
January 6, 2021
Question

Changing an AttributeDef type

  • January 6, 2021
  • 1 reply
  • 193 views

Hi All,

I have a "product" attribute on an element that is set as a String in the EDD. I want to dynamically change it to a Strings type in the document. I have some code I have been playing with, but it is not quite ready for the world to see--and besides, it doesn't work. Has anyone done a task like this in ExtendScript or the FDK that could share some pointers? Thank you in advance.

-Rick

This topic has been closed for replies.

1 reply

Inspiring
February 6, 2021

Hi,

 

I've not tested this, but it will be something like this:

var elemDef = app.ActiveDoc.GetNamedElementDef('FooBar');
var attrDefs = elemDef.AttributeDefs;

for (var i = 0; i < attrDefs.length; i++) {
	if (attrDefs[i].name === 'product') {
		attrDefs[i].attrType = Constants.FV_AT_STRINGS;
	}
}

elemDef.AttributeDefs = attrDefs;