Problems with Function Parameters and having to use different ones to Associate a Workflow

Problems with Function Parameters and having to use different ones to Associate a Workflow

Hi All!

I am not sure if this is a problem, a limitation of the system or that I haven't figured it out how to use it appropaitely.

So, I finally managed to be able to create some functions. I managed to run it successfully and I decided to use it to solve a problem I have been having for months and the built-in "Field Update" in Workflows can not solved. Basically, is updating a field in the record producing the trigger, but with data from a different associated record and nested in conditionals. It is strange that the Field Update functionality has not the ability to "merge" with associated records, as I have seen that functionality in other parts (such as configuring parameters for Funtions).

So, I built this function, I assigned it 3 parameters: record 1 id, record 2 id and a string variable that will receive as parameter the API name I want to use upon a condition being met.

The logic I wanted to apply is: If record A has in field "a" option X, get from associated record B the value in field "bx", with API_name_bx. If record A has in field "a" option Y, get from associated record B the value in field "by", with API_name_by.

The problem I faced, was that when I was configuring the workflow, I associated for the first condition the function, I was able to merge both record ID and even specified a text (API_name) and I had the 3 parameters. The function run, all good.
But then, when I went to the second conditional, and when I selected the Function, I was not able to specify different input parameters! So odd, what is the point of having a function with parameters if I can not change the parameters I pass when I call it?? Im pretty sure I must be wrong.

So, long story short, I ended up duplicating the function 4 times, one for each conditional, to be able to just run 1 workflow (I actually first tried to create 4 different workflows but when I wanted to use the same function, it was configured as I used it in the previous workflow and I did not met the use case).

Would someone advise how you would have solved it better? I know I could have created if statements in the original function, but I really wanted to create something more flexible and just pass it different arguments as required, as this will be easier to manage or maintain without touching the code of the function.

Thanks in advance!

J.