Hi Saif!
If I understand you correctly, you want to give the developer the opportunity to select and pass the location of the entity that is used to store the image? Does this mean that the developer has access to the widget settings?
Because if so, you can add a string property in the widget XML that the developer can use to fill in the module-name, and one string property to fill in the entity-name.
These will show in the widget settings in Studio Pro.
Like this:
<property key="moduleName" type="string">
<caption>Name of module</caption>
<description>The exact name of the module.</description>
</property>
<property key="entityName" type="string">
<caption>Name of entity</caption>
<description>The exact name of the entity.</description>
</property>
Make sure that caps are set correctly, as this renders literally.
When you render your widget, you can use those properties to create a variable which represents the correct module and entity.
Like this:
moduleEntityName () {
const { moduleName, entityName } = this.props;
const combinedName = `${moduleName}.${entityName}`;
return combinedName;
};
Then use the combinedName in your mx.data.create function,
const customName = moduleEntityName();
mx.data.create({
entity: customName;
// other parameters });
This way you can dynamically use different module- and entitynames in the same code.
If the developer should not able to configure the widget settings in Studio Pro, then you can use eventListeners and onclick-actions to perform the same logic based on for instance the dataview. This will be a bit more complex though.
Hope this helps! If you need assistance, please reach out!
Best regards, Stefan.