Changing an AttributeDef type

Adobe Community Professional ,
Jan 06, 2021

Copy link to clipboard

Copied

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

TOPICS
Scripting, Structured

Views

42

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 05, 2021

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more