Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, February 22, 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 with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button Click
Mike Underwood
Posts: 3
 
Problem with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button ClickYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Aug 13 4:29 PM

Hi All,


 


I hope you can Help, I have done a Lot of SLX Bespoke but this is the First external VB.NET app I have done.


I have Started with Ryans Tuts and got My Base Class (Class1) and this then opens my form passing an ACCOUNTID and then populating an Editable Grid View with all the contacts from the ACCOUNT, this works fine.


This allows the user to edit, add contacts in a spreadsheets fashion and then update all with a single click.


The problem I am having is that all my SLX references work fine in the base class (Class1) but I get the dredded "Object reference not set to an instance of an object" when running them from my (Form1) class.


I have tried with the Function in the Class1 and in the Form1 class to no avail.


My knowledge of VB.NET is quite new so please excuse the simplicity of the code.


 


I create a new instance of the Class1 (Class3) in my Form1 class but still get the error. 


 


 


<p>Imports System.Data.OleDb

 


Imports Sage.SalesLogix.NetExtensions


Imports Sage.SalesLogix.NetExtensions.BaseRunnable


 


Public Class Class1


    Inherits Sage.SalesLogix.NetExtensions.BaseRunnable


    Public FormGrid As New Form1


 


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


        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 & _


                            "Current Accountid: " & SlxApplication.BasicFunctions.CurrentAccountID & vbCrLf & _


                            "Connection String: " & SlxApplication.ConnectionString


        Call ShowForm()


 


        Return Nothing


 


    End Function


 


    Public Sub ShowForm()


 


        Dim connection As OleDbConnection


        Dim oledbAdapter As OleDbDataAdapter


        Dim ds As New DataSet


        Dim sql As String


 


        sql = "SELECT CONTACTID, FIRSTNAME, LASTNAME, TITLE, WORKPHONE, EMAIL, AFPTIS_STATUS, ISPRIMARY FROM sysdba.CONTACT WHERE ACCOUNTID = '" & SlxApplication.BasicFunctions.CurrentAccountID & "'"


 


        connection = New OleDbConnection(SlxApplication.ConnectionString)


 


        FormGrid.SLXConnection = SlxApplication.ConnectionString


        FormGrid.SLXAccountID = SlxApplication.BasicFunctions.CurrentAccountID


        FormGrid.Show()


 


        Try


            connection.Open()


            oledbAdapter = New OleDbDataAdapter(sql, connection)


            oledbAdapter.Fill(ds)


            oledbAdapter.Dispose()


            connection.Close()


 


            FormGrid.DataGridView1.AutoGenerateColumns = True


            FormGrid.DataGridView1.DataSource = ds.Tables(0)


            FormGrid.DataGridView1.Columns(0).Visible = True


            FormGrid.DataGridView1.Refresh()


        Catch ex As Exception


            MsgBox(ex.Message)


        End Try


    End Sub


End Class


 


 


 

<p>Imports System.Windows.Forms

 


Imports System.Data.OleDb


Imports Sage.SalesLogix.NetExtensions


Imports Sage.SalesLogix.NetExtensions.BaseRunnable


 


Public Class Form1


 


    Public SLXConnection As String


    Public SLXAccountID As String


 


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


 


        Dim connection As OleDbConnection


        Dim oledbAdapter As OleDbDataAdapter


        Dim ds As New DataSet


        Dim sql As String


        Dim RowCount As Integer


 


        RowCount = DataGridView1.RowCount - 2


 


        connection = New OleDbConnection(SLXConnection)


 


        Call GetNewIDforContact()


 


        Try


            connection.Open()


 


            For i = 0 To RowCount


 


                sql = "UPDATE sysdba.CONTACT SET AFPTIS_STATUS = '" & Trim(DataGridView1.Item(6, i).Value.ToString) & _


                "' , FIRSTNAME = '" & Trim(DataGridView1.Item(1, i).Value.ToString) & "' , LASTNAME = '" & Trim(DataGridView1.Item(2, i).Value.ToString) & _


                "' , TITLE = '" & Trim(DataGridView1.Item(3, i).Value.ToString) & "' , WORKPHONE = '" & Trim(DataGridView1.Item(4, i).Value.ToString) & _


                "' , EMAIL = '" & Trim(DataGridView1.Item(5, i).Value.ToString) & "' , ISPRIMARY = '" & Trim(DataGridView1.Item(7, i).Value.ToString) & _


                "' WHERE CONTACTID = '" & Trim(DataGridView1.Item(0, i).Value.ToString) & "'"


 


                oledbAdapter = New OleDbDataAdapter(sql, connection)


                oledbAdapter.Fill(ds)


 


                oledbAdapter.Dispose()


 


            Next


 


            MessageBox.Show("Finished", "Finished")


            connection.Close()


 


        Catch ex As Exception


            MsgBox(ex.Message)


        End Try


 


    End Sub


 


    Public Function GetNewIDforContact()


 


        Dim Class3 As New Class1


        Dim ContactID As String


 


        MsgBox("I am Here")


 


        ContactID = Class3.SlxApplication.BasicFunctions.GetIDFor("contact")


 


        MsgBox(ContactID)


 


        Return ContactID


 


    End Function


 


End Class


 


 



 


 


 

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Problem with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button ClickYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Aug 13 12:17 AM

What specifically is the object that it is complaining about? Which line?


At first look, I am guessing that the problem is that the FormGrid object isn't accessible from outsde the form (by default controls are private in scope, at least they are that way in C#, I don't use VB.NET). If this is the case, you can click the control on the form and look for a property called, can't remember what the property is called, something like access modifier, it will have choices like Private, Public, Friend, etc. Change it to public (again, if it is the FormGrid that the error is referring to)


 


 

[Reply][Quote]
Mike Underwood
Posts: 3
 
Re: Problem with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button ClickYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Aug 13 1:53 AM

Hi Ryan,


 


Thank you for the reply.


 


The line which is causing the reference error is below.


 


ContactID = Class3.SlxApplication.BasicFunctions.GetIDFor("contact")


 


This line is in the Form1 class, if I call the same from the base class (Class1) it works fine, it only errors when I call it from the Form1 class Button Click.


 


Mike

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Problem with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button ClickYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Aug 13 2:24 AM

SlxApplication is not a public property of the class. Add something like this to the class:


 


Public Function GetIdFor(ByVal Table As String) As String
Return SlxApplication.BasicFunctions.GetIDFor(Table)
End Function

 


 


Then you'd use it like this (using Class3 as your variable name for Class1 as you had in your code):


ContactID = Class3.GetIdFor("Contact")

 


Alternatively, you could implement the IRunnable interface instead of inherting from BaseRunnable, then make the SlxApplication variable public.

[Reply][Quote]
Mike Underwood
Posts: 3
 
Re: Problem with GetIDFor (Or Any SlxApplication Methods) from a VB.NET Form Button ClickYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Aug 13 4:12 AM

Hi Ryan,


 


Thank you so much for your Help.


I can't seem to get it to work at all, Irunnable or other, still get the Object reference error, probably my understanding of VB.NET.


 


I have implemented dbids and that is working fine.


 


 


<p> 



Public Function NewID(ByVal table) As String

 


        Dim conn As New OleDbConnection(SLXConnection)


        Try


            conn.Open()


            Dim cmd As New OleDbCommand(String.Format("slx_dbids('{0}', 1)", table), conn)


            Return cmd.ExecuteScalar().ToString()


            cmd.Dispose()


        Finally


            conn.Dispose()


        End Try


    End Function


 


 


 

[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/22/2025 3:43:14 PM