import reusable function from another snippet/python?
Posted: Tue Sep 06, 2022 2:21 pm
Hi-
I have several snippets where they all do a similar thing, and so it occurred to me that I should refactor the code such that the reusable part can be called by all of them where they would simply pass a parameter for each caller to achieve its desired affect on the Order.
A's snippet:
Call R.DoThatThing(1);
B's snippet:
Call R.DoThatThing(2);
C's snippet:
Call R.DoThatThing(3);
R's snippet:
Define function DoThatThing(i) where maybe it adds an Order Note with a message including parameter i;
While it is straight forward to do this in Python via import, I'm not sure how to do this within the SPS automation snippet environment.
Thoughts?
I have several snippets where they all do a similar thing, and so it occurred to me that I should refactor the code such that the reusable part can be called by all of them where they would simply pass a parameter for each caller to achieve its desired affect on the Order.
A's snippet:
Call R.DoThatThing(1);
B's snippet:
Call R.DoThatThing(2);
C's snippet:
Call R.DoThatThing(3);
R's snippet:
Define function DoThatThing(i) where maybe it adds an Order Note with a message including parameter i;
While it is straight forward to do this in Python via import, I'm not sure how to do this within the SPS automation snippet environment.
Thoughts?