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: .Net Extension - passing variable back
Andrew Grandin
Posts: 272
 
.Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Oct 09 11:16 AM
I have the usual .Net extension working whereby a message box is displayed which uses an argument passed from SLX to the .Net Extension as below:

Dim msg As String = "Hello .NET-SalesLogix World!" & vbCrLf & vbCrLf & _
"Argument passed: " & IIf(Args.Length = 0, "None", Args(0)) & vbCrLf & _
"Current userid: " & SlxApplication.BasicFunctions.CurrentUserID() & vbCrLf & _
"Andrews 2nd Test Connection String: " & SlxApplication.ConnectionString

how do i pass an argument from the .Net extension to SLX??? So whereas SLX passes the IIf(Args.Length = 0, "None", Args(0)) to the extension, how could i fill a text box on my form in SLX with the value of ""Andrews 2nd Test Connection String"", or whatever text i choose to put there????

If it helps i have the following:

For i As Integer = 0 To 5

Dim returnString As New StringBuilder(250)
result3 = QAProWV_UIGetResult(i, returnString, 250)
MessageBox.Show(returnString.ToString())

which displays 6 MessageBox's each showing a different line of an address. I want each line read in to a different text box on my form so i need to know how to pass the variable
returnString to SLX for display after each pass through the For Loop.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 12:27 AM
In your .NET Extension you'll notice the signature for Run is as follows:

Public Overrides Function Run(ByVal Args() As Object) As Object


It returns an object, so you're basically able to pass back any simple or complex type you'd like. Your extension could look like this:

Public Overrides Function Run(ByVal Args() As Object) As Object
Return "Hello World"
End Function


Then, in SalesLogix, your script would look like this to get the returned value:

Dim ext ' this variable will hold the handle for the loaded .NET Extension
Dim retvalue ' this will hold the value returned from the .NET Extension

' instanciate the .NET Extension
ext = Application.Managed.Create("SLX NET Extensions Test", "ClassLibrary1.Class1")

' run it and capture the returned result from Run into retvalue
retvalue = Application.Managed.Run(ext, Empty)

' place the value in a textbox if you'd like
textbox1.Text = retvalue

' destroy the loaded .NET Extension
Application.Managed.Destroy ext


Does that make sense?
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 4:06 AM
Thanks Ryan, ill give a go and see what happens.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 4:16 AM
Hi Ryan,

I already have a Application.Managed.Run in order to pass a value into my .Net Extension:

Dim ext ' this variable will hold the handle for the loaded .NET Extension

' instanciate the .NET Extension
ext = Application.Managed.Create("ClassLibrary2", "ClassLibrary2.NewClass")

' run it (and pass address string to search on)
Application.Managed.Run ext, edit6.Text

' destroy the loaded .NET Extension
Application.Managed.Destroy ext

Do i add your Application.Managed.Run line also?
[Reply][Quote]
john
Posts: 34
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 4:50 AM
I think what Ryan is getting at is to amend your code to something like :

Dim ext ' this variable will hold the handle for the loaded .NET Extension

' instanciate the .NET Extension
ext = Application.Managed.Create("ClassLibrary2", "ClassLibrary2.NewClass")

' run it (and pass address string to search on)
sReturnString = Application.Managed.Run (ext, edit6.Text)

' destroy the loaded .NET Extension
Application.Managed.Destroy ext

And then amend the .net extensions Run method to return back the address using the return statement - make sense?
So at the end of the Run method, when you have an address add something like:
Return returnString.ToString();
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 5:04 AM
Thanks guys ill give it a go......
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 5:10 AM
I tried your suggestion guys and it worked...but only for a single pass through the loop. I chnaged my extension to the following:

For i As Integer = 0 To 5
Dim returnString As New StringBuilder(250)
result3 = QAProWV_UIGetResult(i, returnString, 250)
MessageBox.Show(returnString.ToString())
return returnString.ToString()
Next

And chnaged my SLX code to the following:

Dim ext ' this variable will hold the handle for the loaded .NET Extension
Dim sReturnString

' instanciate the .NET Extension
ext = Application.Managed.Create("ClassLibrary2", "ClassLibrary2.NewClass")

' run it (and pass any arguments)
sReturnString = Application.Managed.Run (ext, edit6.Text)
edit7.Text = sReturnString
' destroy the loaded .NET Extension
Application.Managed.Destroy ext

But when i tested it only the first line of the address was displayed in a msg box and placed into the text box. I was expecting 6 message boxes, one for each line of the address.
[Reply][Quote]
john
Posts: 34
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 5:21 AM
You can only return one thing using the Return statement...

Could you change your .net extension to return a string array, where each array item is one of the address lines?
Then you would populate the array in the For Loop and return the array once the for loop had completed.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 5:27 AM
That certainly sounds like the way to go, i know the API function will only recognise a stringBuilder so i couldnt use an array directly with the function but i could read the results into an array as it loops and try and pass that. Thanks john.
[Reply][Quote]
Trent Haynes
Posts: 32
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 7:10 AM
Another way to try this is to add public properties to your .NET object and reference those properties from SLX. You could also add other public methods to your object, and capture the return value from those in SLX.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 7:13 AM
Thanks for all your help guys ive got it all to work now. I use the following in my .Net Extension:

For i As Integer = 0 To 5

Dim returnString As New StringBuilder(250)
result3 = QAProWV_UIGetResult(i, returnString, 250)
MessageBox.Show(returnString.ToString())
Array(i) = returnString.ToString()
Next
return Array(0) +"," + Array(1) +"," + Array(2) +"," + Array(3) +"," + Array(4) +"," + Array(5)


Then in my SLX script i used the SPLIT function to separate the values back out:

Dim a
a = Split(edit7.Text,",")
edit8.Text = a(0)
edit9.Text = a(1)
edit10.Text = a(2)
edit11.Text = a(3)
edit12.Text = a(4)
edit13.Text = a(5)
[Reply][Quote]
john
Posts: 34
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 8:11 AM
unless you are 100% sure that QAS will never return a comma in its address lines, I would use a different delimiter, such as the pipe character |
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: .Net Extension - passing variable backYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Oct 09 8:24 AM
Good point, i have changed it accordingly, 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 5:51:24 PM