Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

How can I know what kind of field is?

Avatar

Former Community Member
Hi,



I have a function that receive a field, and depends of the kind of field (Text, numeric or date) is necesary execute a expecific script.



Is it possible ask to the field if it is a numeric, text or date field?



Thanks
8 Replies

Avatar

Level 5
I have no straight answer for this situation... However you may achieve this using workaround methods using following two properties...



$.name or this.name gives you the name of the fields you gave at design time. So name those three fields they way you can easily identify their type with their name. And build you logic based on that.



You may also use $.className or this.className to get what kind of the field it is but not to the granularity to the level of your expectation.



I prefer the first one. Try that and let us know what you found.



Good luck,

SekharN

Avatar

Former Community Member
hi chris,



i've been looking at this tutorial. i found a sample in it, but i can't open it with the designer to see the code it uses, cause it is pw protected. this doesn't help me much ;-)



i've tryed to use className to get the fieldType but i only get 'field' back, which is not a help at all.



could you send the pw or eventually the code behind the sample?



and also, can i change the type at run time? i.e. from textEdit to numericEdit.



thanks, valerio

Avatar

Former Community Member
Hi Valerio,



Maybe this will help you, it is a code snaptshot from my form, its identifies a field inside an if statement:



if (xfa.form.MyForm.pageSet.Page1.MyField.ui.oneOfChild.className =='textEdit')



Hope it helps.

Avatar

Former Community Member
hi ruben,



thanks for answering. i've got this!

can i then change the type of a field via java script at run time?



if you have a solution, please let me know.



valerio

Avatar

Former Community Member
Well, that's useless. I have no idea what the password is :(



Seems like you have the idea of how to check the field type in script. You can't change the field type programmatically though.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
hi chris,



thanks for answering ... even though you bring bad news ;-(



i'll try something else to get what i want. it's always the same strategy anyway, isn't it ?



regards,



valerio.

Avatar

Former Community Member
Valerio_Chiessi@adobeforums.com wrote:

> hi chris,

>

> thanks for answering ... even though you bring bad news ;-(

>

> i'll try something else to get what i want. it's always the same strategy anyway, isn't it ?

>

> regards,

>

> valerio.



Valerio,

What exactly are you trying to accomplish? I'm not sure why you would want to change the type of

field at runtime.



--

Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com