Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, February 21, 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 .NET Extensions
Forum to discuss the use of .NET Extensions in SalesLogix version 7 and higher. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix .NET Extensions | New ThreadView:  Search:  
 Author  Thread: Calling SLX function from VB.net
Matias
Posts: 23
 
Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Dec 07 7:57 AM
Hi,

I'm trying to do an Account class. This class will have any functionality required for SLX to add, edit or show an Account.
My problem it’s that I know that I can call SLX function from SLX, but I don’t know exactly how:

My code is this:

Public Sub Add(ByVal Account As Account)
Dim sSQL As String
Dim AccountID As String
Dim AddressID As String
Dim slxAPP As SalesLogix.ISlxApplication

SetConnection(Account.DataBaseName, Account.ServerName)

If oConnection.State = 0 Then
oConnection.Open()
Else
oConnection.Close()
End If

sSQL = "SELECT * FROM ACCOUNT WHERE 1 = 2"

AccountID = slxAPP.BasicFunctions.GetIDFor("ACCOUNT")
AddressID = slxAPP.BasicFunctions.GetIDFor("ADDRESS")

oRecordset.Open(sSQL, oConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockBatchOptimistic)

sSQL = "INSERT INTO ACCOUNT (ACCOUNTID, ACCOUNT, SECCODEID, ACCOUNTMANAGERID,ADDRESSID) VALUES (" & AccountID & ", " & Account.Account & ", " & cSeccodeID & ", " & cAccMgrID & ", " & AddressID & ")"

oCommand.ActiveConnection = oConnection
oCommand.CommandText = sSQL
oCommand.Execute()


End Sub

I know that I need something else because Visual Studio it’s telling me that "slxAPP" it’s being used before has any data assigned.

Any help will be appreciated.

Thanks
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Dec 07 10:52 AM
The error you're getting is accurate. Although you've created the slxAPP variable, you've not assigned anything to it. You need to instanciate a reference to the SlxApplication object to assign to that variable. Does that make sense?

Add a line like this:

slxAPP = New SalesLogix.SlxApplication()


Does that make sense?

-Ryan
[Reply][Quote]
Matias
Posts: 23
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Dec 07 11:51 AM
Thanks Ryan for the quick reply.

Yes, that solves the problem. But now I have a new one.

Now I got this error: "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified", in this line

AccountID = slxAPP.BasicFunctions.GetIDFor("ACCOUNT")

Another thing happens too, when I add the line you said, it opened SLX. My question is, when I call this from SLX, it’s going to open another SLX App or it going to use the one that’s already opened.


Thanks
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Dec 07 12:06 PM
Yes, the SLX client *MUST* be running in order to use the SlxApplication object. If all you need it for it to create table ID values, then use the slx_dbids proc instead.
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Dec 07 6:59 AM
Matis,

What I generally do is write a wrapper class around both the connection and the application so that all my code can be orchastrated thu it. While in initial development to avoid to many update extensions run SLX paths, my test harness sets the connection properties.

All Slx Functionality basically checks to see if the application is initialized and deprecates if nessacary. When I am at the point of testing something that really has to be integrated such as a BasicFunctions call I then initialize my connection proxy with the valid client connection and application instance and since all my code uses this class no core changes need to be made.

in the run method ....

SLXConnection conn = new SlxConnection(m_application.ConnectionString)
conn.Application = m_Application;


in the code

if (m_Connection.Application != null)
m_Connection.Application.BasicFunction.Create....


Even more so, I also abstract all database side calls into DataEngine classes that take the SLXConnection as a Constructor so that at the form level there is no data access code, just method calls against the appropiate dataengine. These dataengines are derrived from a base data engine that has calls like

ExecuteReader
GetQueryResults
...

So that in the data methods calls that deal with business i can do

string accountID = this.GetNewIDFor("Account")[0];

- or -

string accountName = ExecuteSQLReturnScalar(string.Format("Select Account from Account where AccountID = '{0}'", accountID);

I really do not want to duplicate the data access code (Connection build up, command ...)

I also have created a small entity layer so that I can work against Account/Contact ... and any other values at the object level. So I do have method calls in my code such as

Contact currContact = DataEngine.GetEntityByID("AKE1234");

and also

List contactList = DataEngine.GetEntityList();
List contactList = DataEngine.GetEntityList(string.format("Select * from Contact where Type = '{0}'", contactType)

Regards,
Mark






[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Dec 07 7:01 AM
Matis,

since you are using vb.net why not use the OleDb functionality instead of using standard ADO calls?

Mark
[Reply][Quote]
Matias
Posts: 23
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Dec 07 7:01 AM
Thank you all for the answers, i managed to solve the problem with the account id with a custom Function.

But now i have a problem when i want to test the DLL in SLX. The thing is that the Run method its returning "Nothing" and i want the the Run method return an Account object. here is the code:

The run method:

Public Overrides Function Run(ByVal Args() As Object) As Object
Dim a As New Account
Run = a
End Function

The call in SLX:

Sub Button1Click(Sender)
Dim Guid, A
'stop
Guid = Application.Managed.Create("ClassLibrary1", "ClassLibrary1.Account")

If Not IsEmpty(Guid) Then
Dim Args(1)
Args(0)= "A"
'Application.Managed.Run Guid, Args
A = Application.Managed.Run (Guid, Args)
If Not A is Nothing Then
A.ServerName = "DESAR05"
A.DataBaseName = "SLXRARITAN72"
A.Account = TextBox1.Text

A.GetByID "ATTAG0000009", ext

msgbox A.Account
End If
End If
application.Managed.Destroy Guid
End Sub
[Reply][Quote]
Trent Haynes
Posts: 32
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 07 8:32 AM
Public Overrides Function Run(ByVal Args() As Object) As Object
Dim a As New Account
--> return a (instead of Run = a)
End Function
[Reply][Quote]
Jason Huber
Posts: 77
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 07 5:08 PM
return and run = a are the same in vb.net
C# programmers usually hate this and return works, so I use it in both cases.

I think the problem is RUN should return a reference to the object, not to a new account (you are then creating an account within your account)
Since Run is being called an Account instance is made. you just need to return that instance to SLX.
So.

Public Overrides Function Run(ByVal Args() As Object) As Object Implements iRunnable.Run
Run = Me
'or
'Return Me
End Function

I just checked page 364 in the LAN developers training manual and it is in fact Return Me there, but = should work as well (unless I am missing something with setting an object reference. I already said I used Return Me didnt I?)
Its also on page 347 as Return with the Implements statement.....
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Jan 08 9:30 AM
Hey Jason, Since he is creating a new instance of account (a) and returning it using the assignment operator (I hate this BTW) he should be fine with the .net extension side. Now since this is a reference being passed back the other side of the equation (VB Script) needs inspection. With closer look at the script code he is just using variable assignment x= Application.Managed.Run ( ... Because he is returning an object (pointer) he should actually be using the Set a = Application.Managed.Run .... this is a difference to how .net works where everything is an object so no need for set and VB Script.

Cheers, and Happy New Year.
Mark
[Reply][Quote]
Jason Huber
Posts: 77
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Jan 08 10:00 AM
I didnt catch that part. Your right about set on the slx side, but why would we need to create another account in the run? I mean what he is doing is ok, but unecessary...

I bet the set will fix him up either way! Good catch.
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Jan 08 10:27 AM
Correct, on the creation of the account. I did not look at the create call and specifically the type name. Returning 'Me' would definately work. I think their is a problem with the metaphors in the clarity of the code. In my mind account is an entity, business object container and should be considered such. The runnable code class is a facade which should act as a broker between the .net code and saleslogix and should not contain much code at all. Their is an exception to the rule when you are exposing UI and the Usercontrol implements IRunnable though just for the simplification of it all, however using some MVP/MVC pattern would still split most of the code out of that layer as well. So the final outcome should be

Sub Run ....

BuildUp(args)

return me

End Sub

or better yet

Sub Run ...

dim acct as new Account()
return acct

end sub

And the created .net extension class would be "AccountManager" or something like that.

Make sense?

Happy New Year.
Mark
Mark
[Reply][Quote]
Matias
Posts: 23
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jan 08 6:55 AM
Hello, happy New Year and thanks for all the support.

I have to tell you that I’ve tested all the recommendations that you said but no one seems to work. I tested the "Return a" the "Run = a" the "return me", the "Set a = ", but it still seems that the run method it’s not "running" or it’s not returning any data.

I don’t' know if there is another way to do this, but I need to access to the functionalities of the Assembly within SLX.

Thank you all
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jan 08 7:02 AM
Matias,

First of all is the create method returning a vaild guid. It is a string and should not be empty. Next in your run method in the .net extension you can either debug it by attaching to the SLX process within your solution and setting a breakpoint on the method, or simply add a MessageBox.Show call to display a message inside to see if it is indeed run.

Mark
[Reply][Quote]
Matias
Posts: 23
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jan 08 8:28 AM
Yes, i tested that. It runs, it shows the message box, but it not returning an object with the whole class for me to work with, inside SLX. I've tested the tutorial inside .net Extensions and it works. that it, only a message box, and i can't find anywhere a example on how to do this.
[Reply][Quote]
Matias
Posts: 23
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Jan 08 6:53 AM
Well, guys, i just wanted to let you know that i was able to fix the problem by making the class inherits from System.ComponentModel.Component.
And Thats it.
Thank you all for the support
[Reply][Quote]
Jeff L
Posts: 65
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jul 08 1:09 AM
Matias,

Can I ask, which version of SalesLogix are you working with?

Which version of .Net (Visual Studio).

What interop file did you use in you .net to get the SalesLogix functions?
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Calling SLX function from VB.netYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Jul 08 7:37 AM
Jeff,

Slx 7.x , Visual Studio 2005-2008, .net framework 2.0+, Sage.SalesLogix.NetExtensions.Framework

Mark
[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): 2/21/2025 11:56:55 PM