The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Calling functions
Posted: 17 Aug 09 3:43 AM
|
Hi all, i have a function on in sales process script that i am trying to call in another form. i thought functions were public as i already have this function being called from the SP_SalesPorcessFunctions script but i keep getting a 'variable undefined' error when trying to call it from my form. Am i getting the concept of calling functions wrong? |
|
|
|
Re: Calling functions
Posted: 17 Aug 09 9:13 AM
|
You probably need to "Include" your script so that the functions that you are trying to execute become available. |
|
|
|
Re: Calling functions
Posted: 17 Aug 09 9:31 AM
|
But the function is inside the script on a form plugin, which cant be included like script plugins. |
|
|
|
Re: Calling functions
Posted: 17 Aug 09 9:46 AM
|
Then you need to either copy it over to the other form (so you have it on both places), or move it to a Script and then include the script on both forms.
|
|
|
|
Re: Calling functions
Posted: 17 Aug 09 9:52 AM
|
that was my first thought but the function is using variables that are declared and populated in the form it is currently in. If i copy it over its a bit beyond my expertise how to get the variables to come with it. |
|
|
|
Re: Calling functions
Posted: 17 Aug 09 9:58 AM
|
Got it.
Are you trying to invoke the function on the form + having it do somehting against the form where it is being hosted? Or are you just trying to do a similar thing on a separate form?
If a function depends on items within the Form it is being hosted, then it is not likely that you can port it to other functions. Now, if you are just trying to call a Function on a different form, then you could do so by getting a reference to that form and call it that way. Again, it depends on what the function does.
If I have a Form called X with a Function called "EnableControls" which enables all controls on it, and I want to call it from a different form, then I will need to get a reference to Form X and call the function. (Off course, it will enable the controls on Form X, not on the calling form).
Now, If I have a Function called GetOverallDiscount which figures out a Discount Percentage given an OpportunityID, I would put it on a script and make sure that it didn't rely on any specific Form controls. Then I could include that script on any form and be able to quickly acquire a Discount Percentage. |
|
|
|