Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
csidda
Contributor II
Contributor II

User defined transformations using addons

Hi Team,
I am trying to have the user-defined functions in Functions > user defined functions which I am unable to do.
I followed the documentation steps and below are some attached code 
I used vscode to compile and generate MyTransformation.dll and MyTransformation.so files which I copy pasted manually in the path (C:\Program Files\Attunity\Replicate\addons\samples\MyTransformation)
and the  addons_def.json.sample looks like below 

csidda_0-1667948383590.png

and the MyTransformation.c looks like below in the path (C:\Program Files\Attunity\Replicate\addons\samples\MyTransformation)

csidda_1-1667948443594.png

I also restarted the replicate service after registering the file path. It still doesnt show any function. 

csidda_2-1667948574668.png

Any suggestion or guidance here is appreciated. thanks.  

#addons

Labels (3)
1 Solution

Accepted Solutions
Bill_Steinagle
Support
Support

Hi,

Thank you for the post to the Forums. Here are some helpful steps along with the Documentation for the addon and implementation. Did you run the registration of the addon.def as shown and step 4 as this is how it gets loaded to the UI Replicate Console Functions user defined I believe.

Usage Notes

  1. Create a shared library that implements and exported initialization function:
     

typedef int AR_ADDON_INIT_FUNC(AR_ADDON_CONTEXT *context);

All the types and prototypes are defined at 'ar_addon.h'

  1. Place the built library in <installation_dir>\addons directory.
  2. Register the library at addons_def.json
     

{

"addons": [{

"name": "MyTransformation",

"type": "STARTUP",

"lib_name": "MyTransformation.dll",

"init_function": "my_transformation_init_func"

}]

}

  1. In order to register a user transformation function it should be registered in the addon initialization function:
     

transdef = GET_AR_AO_TRANSFORMATION_DEF();

transdef->displayName = "prefix_with(X, Y)";

transdef->functionName = "prefix_with";

transdef->description = "prefix_with adds the prefix <Y_> to a given string X";

transdef->func = trans_prefix_with;

transdef->nArgs = 2;

AR_AO_REGISRATION->register_user_defined_transformation(transdef);

  1. The new prefix_with function will be available on the GUI under Functions->user defined

 

Implementation Notes

  1. Replicate extension infrastructure:
    UDT is a private use case of product extension/addon. In the future we may want to add User defined datatypes, Metadata hooks, etc..
    the Extension libraries should not be linked with Attunity libraries but only use an public C interface that will be kept between versions.
  2. User defined transformation:
    register an extension that add an Sqlite user defined function that will be able to be used on all the product expressions.
  3. New L_ADDONS logger will be added to be used as logger for all add-ons code prints
  4. Definition structures should be return based on enum of type+version to get 'versioned' structure.

 

Bill

 

View solution in original post

6 Replies
kmadhavi2
Employee
Employee

HI,

Please try to uncomment lib_path(.dll location) in your addon_def.json

Thanks

Heinvandenheuvel
Specialist III
Specialist III

You need to remove the // before  lib_path if you use a non-standard path.

But it may be easier to just use the standard path : MyTransformation\MyTransformation.dll

Doe NOT use the 'samples' path.

And I don't think you need the \\, just a \  will do if you anchor your path - without anchor it will be relative to the installation directory.

Hein.

csidda
Contributor II
Contributor II
Author

Hi, 

I tried to follow the steps which you mentioned. But still not able to fix. Here is my json file . 

csidda_0-1669038792162.png

I have compiled and got these files and pasted in the path below:

csidda_1-1669039214577.png

In the documentation it is written that dll file is automatically generated, I am not clear on this part. I have compiled the files manualy using the gcc command and added all the file in the path mentioned. Do correct me if the approach which I have taken is incorrect. 
The documentation is bit ambiguous in  nature and makes few assumptions that the user is aware of. Do forgive me for any misunderstandings as I am a newbie to Qlik and only getting used to it.

Chaithra 

Bill_Steinagle
Support
Support

Hi,

Thank you for the post to the Forums. Here are some helpful steps along with the Documentation for the addon and implementation. Did you run the registration of the addon.def as shown and step 4 as this is how it gets loaded to the UI Replicate Console Functions user defined I believe.

Usage Notes

  1. Create a shared library that implements and exported initialization function:
     

typedef int AR_ADDON_INIT_FUNC(AR_ADDON_CONTEXT *context);

All the types and prototypes are defined at 'ar_addon.h'

  1. Place the built library in <installation_dir>\addons directory.
  2. Register the library at addons_def.json
     

{

"addons": [{

"name": "MyTransformation",

"type": "STARTUP",

"lib_name": "MyTransformation.dll",

"init_function": "my_transformation_init_func"

}]

}

  1. In order to register a user transformation function it should be registered in the addon initialization function:
     

transdef = GET_AR_AO_TRANSFORMATION_DEF();

transdef->displayName = "prefix_with(X, Y)";

transdef->functionName = "prefix_with";

transdef->description = "prefix_with adds the prefix <Y_> to a given string X";

transdef->func = trans_prefix_with;

transdef->nArgs = 2;

AR_AO_REGISRATION->register_user_defined_transformation(transdef);

  1. The new prefix_with function will be available on the GUI under Functions->user defined

 

Implementation Notes

  1. Replicate extension infrastructure:
    UDT is a private use case of product extension/addon. In the future we may want to add User defined datatypes, Metadata hooks, etc..
    the Extension libraries should not be linked with Attunity libraries but only use an public C interface that will be kept between versions.
  2. User defined transformation:
    register an extension that add an Sqlite user defined function that will be able to be used on all the product expressions.
  3. New L_ADDONS logger will be added to be used as logger for all add-ons code prints
  4. Definition structures should be return based on enum of type+version to get 'versioned' structure.

 

Bill

 

csidda
Contributor II
Contributor II
Author

Thanks Bill for the response. 
Is there any implementation notes or references on how to create a shared library in C ? sorry for being such a noob.
Is there any plan to extend the feature for python ? 

Shai_E
Support
Support

Hello,

This is a video which contains an explanation about shared libraries in C and how to create them on linux, i don't know which OS you are on but i hope this at least helps, and if you have windows maybe you can convert the process.

Write Better Code! | How to Create Shared Libraries in C/C++ - YouTube

Sorry i can't do more on this one im more proficient in JavaScript