I have a transformation that is connected to Desti...
# support
t
I have a transformation that is connected to DestinationA and DestinationB. The transformation does a bunch of property manipulation that both A and B need. However, DestinationB requires a slight difference in handling of one property manipulation. How can I do this within a single transformation? I don't want to have to duplicate the transformation just to handle one small difference. Is the right and only way to build condition logic within the transformation using the metadata based on
destinationType
?
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
q
You can create a transformation library with your common code -> import it in different transformations and modify it as you need to be used by different destinations. https://www.rudderstack.com/docs/features/transformations/libraries/
t
Thanks @quiet-wolf-72320. I could do that but I also found that I can use the event metadata and then filter on the destinationType. e.g.
Copy code
const META = metadata(event);
 const DESTINATION = META.destinationType.toLowerCase();

 if ( DESTINATION == "foo") {
    ...
 } else if (DESTINATION == "bar") {
    ....
 }
The docs should clarify this use case and advice on how you'd use event metadata in other ways (e..g based on source type, etc).