Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, August 29, 2025 
 
slxdeveloper.com Community Forums  
   
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!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Problem calling a function i have created
Andrew Grandin
Posts: 272
 
Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Aug 09 3:32 AM
Due to an earlier customisation i made users can no longer manually check their complete box in a sales process. The complete box and complete date are automatically populated when they click the sales process step. This presented the problem of removing the tick and complete date if they cancel the step. To solve this i created the following function:

function removeChecks(astrspaid)
Dim strKeyField2, strReqStepID, strRegStepName
dim result
strKeyField2 = grdSalesProcess.GetCurrentField
result = DoUnCompleteStep(astrspaid)
grdSalesProcess.Refresh
grdSalesProcess.ExpandAll
UpdateStats(gstrSalesProcessID)
PostOppDetailView
RefreshOppDetailView
end function

This function appears in the Sales Process plugin and is called by SP_SalesProcessFunctions, using removeChecks(astrspaid), when a user cancels a step. The astrspaid already existed in the script providing the salesprocessauditid of the step being clicked.

However i have now been asked to develop a FORM to be called on a particular sales process step which has given me the problem of having to remove the complete tick and date if the user cancels the form. I am having trouble getting the form to properly use the removeChecks function i have written. I have included all the scripts that are included in both other plugins mentioned just to be safe but cant seem to get the function to remove the tick and date when the form is cancelled.

Any ideas? (its just a simple form, 3 buttons, 1 cancel button)

P.S i forgot to mention there is no problem with the function it works perfectly.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Aug 09 12:14 PM
You shouldn't be calling the removeChecks function from your new Form.

The way that I see it is as follows:
- Once the users click on StepX (the one that fires the Form), you launch the form (make sure it is open in Modal mode). When the form closes, you set a Global variable to indicate how it was closed
(or if you created a main view, you could hide the form and then just have a variable within the Form to read how it was closed).
If the Form was "Cancelled", then from the calling script you would launch the removeChecks

Another way to do it:
- From your Form, get a reference to the Opportunity Main View
e.g.
Dim oppView
For i = 0 to Application.MainViews.Count
if Application.MainViews.Item(i).BaseTable = "Opportunity" then
Set oppView = Application.MainViews.Item(i)
Exit For
End If
Next i

- Then loop through the Tabs (check also on the Middle view) and get a reference to the Form object of the Sales Process tab.
e.g.
Dim blFound
Dim spForm
for i = 0 to oppView.Tabs.Count
if oppView.Tabs.Item(i).Caption = "Sales Process" Then
Set spForm = oppView.Tabs.Item(i).Form
blFound = true
Exit For
End If
Next i
if blFound = false
if oppView.MiddleView.Caption = "Sales Process" then
Set spForm = oppView.MiddleView
End If
End If

- Execute the removeChecks() function via the reference to the SalesProcess form (e.g. spForm.Script.removeChecks(id))

By following this method, you are executing the removeChecks function on the Sales Process tab itself, so it has access to all its data, Included scripts and controls.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 3:55 AM
Thanks for you reply Raul ill try my best to get it to work. I have a small problem though, the syntax check is expecting an end of statement after your Next i, in your (- From your Form, get a reference to the Opportunity Main View) section.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 5:33 AM
I got passed the previous error but now i am getting a "Object Required: 'Application.MainViews.Item(...)'"
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 9:29 AM
I thought had fixed the code (at least I did on my test environment):

First of all, Next i should just be Next.

Second, the for loops around the Main views is iterating an extra time. Should be:

For i = 0 to Application.MainViews.Count - 1 'Notice that I added the -1 since it is a zero base Index and we are geting the count of views available.
...
Next
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 9:42 AM
i am now getting an object required: error at line 'for i = 0 to oppView.Tabs.Count'
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 9:45 AM
Same as above, it has to be:

If oppView was set (as in, the Opportunity view was open):

for i = 0 to oppView.Tabs.Count - 1
...
Next
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 9:48 AM
Already tried that and got the same error.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 9:56 AM
Do you have the Opportunity view open?
If you noticed, if not, OppView would be blank, thus it would not be an object.

I think that the problem is this line:
if Application.MainViews.Item(i).BaseTable = "Opportunity" then

The base table is upper case, so try this instead:
if Application.MainViews.Item(i).BaseTable = "OPPORTUNITY" then

[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 10:06 AM
Thanks Raul! Ive said before you're a legend but you have now moved up to Superhero status! One final problem, i have tried calling my removeChecks function using:

spForm.Script.removeChecks(astrspaid) -- with astrspaid being what is used in the script where the function is called.

but im getting an error that astrspaid is undefined. In your original post you said to use spForm.Script.removeChecks(id) but where do i get (id) from?
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 10:12 AM
My assumption is that you have that value.

How are you opening the form? If you are opening from code you should pass the ID to the Form (or put it in a global variable). Then upon closing of the form, get the value from the Global variable and clear it. At that point you should be able to pass it back to the Form.

Or, on the Sales Process tab, set the value into a Global variable and then call it with it instead.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 10:31 AM
My form is opened by attaching it to a sales process step using the Action option in Manage --> Sales Processes in Architect.

Although the function appears in the Sales Process plugin script the astrspaid variable comes from the SP_SalesProcessFunctions plugin script. I found it by placing message boxes at various places until i found the variable that contained the sales process audit id (monotonous i know!).

I found the part of the SP_SalesProcessFunctions that displays the message telling the user they cancelled the step and then called my removeChecks immediately after the message box using removeChecks(astrspaid). I have searched the whole SP_SalesProcessFunctions script and cant seem to find where this variable gets populated.

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 11:45 AM
Andrew:

The original event handler for the Hyperlink on the grid has a parameter called "PrimaryKeyValue", which is the ID of the step that you are executing.
If you look at that code, you will see that it calls DoStepAction and passes that value along.

You could go ahead and add this value to a Global Variable before it invokes "DoStepAction",
e.g. Application.GlobalInfo.Add "SP_mystepID", PrimaryKeyValue

Then, when the user clicks Cancel on your form, you could read this variable and then pass this ID over to the function you created.

[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 3:36 AM
Thanks Raul that has worked. I used Applications.BasicFunction.GlobalInfoFor ("SP_mystepID") to get the variable value. Thanks for all your help.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 3:58 AM
Also Raul, if you fancy another challenge now that the cancel button works, i need to get the same functionality in relation to one of the other buttons. There is another button on my form that when clicked runs the following:

Sub btnPhoneClick(Sender)
application.BasicFunctions.DoInvoke "Function", "Schedule:PhoneCall"
CloseMyForm("MyForm")
End Sub

I now have to try and get the removeChecks function to work if the user clicks my button but then cancels the Schedule Phone Call process. I have a feeling this is going to be more difficult!
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 9:38 AM
Andrew:

Do you have access to the Developer's Reference?

Calling functions is ok, but give you limited control over the results. There are certain built in functions that will do what you are trying to do and give you more control.
For this particular case, why don't you Application.BasicFunctions.CreateActivity? If the user clicks ok, you will receive an ID for the created activity, otherwise you receive an empty string.

e.g.
strActID = Application.BasicFunctions.CreateActivity("Phone Call", "CONTACTID", "OPPORTUNITYID", "Regarding", "Notes", "USERID")
if strActID = "" then
msgbox "User Cancelled"
'Add code to handle cancellation
Else
msgbox "Activity created: " & strActID
End If
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Problem calling a function i have createdYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 9:46 AM
Unfortunately the Developers Reference Guide hasnt been installed. I have got a copy of Devlogix III.7 though. I will give your idea a try and hopefully everything will work ok.

Many many thanks.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/29/2025 12:30:13 PM