67
Views
5
Comments
Is it OK to use widget ids for input parameters in JavaScript?
Discussion

Hi,

Can someone tell me if it is OK to use widget ids for input parameters in JavaScript? Along with the rationale if it is or isn't.  

I know not to target id's in css as they change during runtime but don't know if there is a similar scenario for widget ids in JS.

Thanks

2025-07-31 10-32-21
Vikram garasiya

you can definitely use widget Id in Js it will not cause any trouble while running the application even For some use cases outsystems use widget Id like if you use setActivetab action of outsystems it ask for widget id. 

Hope it will help you. if


Thanks

2022-09-04 15-01-10
JayPea

Thanks, Is it best practice to use WidgetId's can you think of any reasons not to use widget ids?

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @JayPea ,

It is ok to use the special attribute WidgetName.Id, passing that in as a parameter into your javascript node.  The platform makes sure this is unique (i.e. in blocks or lists) in the whole screen, and you don't have to know as a developer up front in design time what exactly it will be.

It is not ok to hardcode a widget id in your javascript code, for the same reasons why you should not target one from your css : there is no guarantee how the platform will give each widget a unique id at runtime, so what works now might not work tomorrow.

Dorine

2022-09-04 15-01-10
JayPea
2025-07-31 10-32-21
Vikram garasiya

we cannot say it is a best practice or bad practice, it will not affect application performance but try to avoid Js as much as possible, Use Js only when things are not defined in outsystems.

Thanks 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.