PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 8/15/2011 11:22 PM by  Scott Ward
Entity Custom Fields
 4 Replies
AddThis - Bookmarking and Sharing Button
Sort:
You are not authorized to post a reply.
Author Messages
Drew Goodwin
New Member
New Member
Posts:3
Points:5


--
8/12/2011 12:34 AM

    Hi,

    In our HelpMaster installation Sites have a number of custom fields defined. When I load a Site through the API and I access the Site.CustomFields collection I see none of them. If I try to set one of the custom fields using SetTextBoxValue(PKID of the custom field definition, custom field value), then I get an exception - which is understandable as I would imagine SetTextBoxValue() updates the in-memory value of an item in Site.CustomFields.

    Is there something else I need to do to have custom fields returned into the Site object? Or is this not implemented yet and I should go directly to the database?

    Kind regards,
    Drew

     

     

    Scott Ward
    HelpMaster development team
    Helpdesker
    Helpdesker
    Posts:25
    Points:29


    --
    8/15/2011 8:57 PM

    Hi Drew

    I’ve just tried accessing and setting Site Custom fields, and have not have any of the issue you mentioned.
     
    If my test code below doesn’t help you fix your issues can you please post some of your code, mainly the bit where you load the site, access the fields and save it again, And some understanding of what you are trying to achieve with the API could Help us.
     
    Also let us know what the exception is saying when you try to update the custom field,  make sure you are calling the correct Set__Value function, there are 4 control types and only one of the Set__Value methods will work for each control type.
     
     
    The code in Red denotes values specific to my test database only
     
     
    ' Start the Helpmaster API
    Dim strMSG As String
    HMPAPI = New HelpMasterProAPI.Connection ' Instantiate the HMP API
     
    ' This values represent the "staff" To log on to The API as.
    ' This value is used when things like logged by/ Actioned by are explicitly set.
    HMPAPI.LoggedOnUserLink = 5618
     
    ' Set the database connection string
    HMPAPI.DatabaseConnectionString = "Data Source=(local);Initial Catalog=HMP11Test;Integrated Security=SSPI;Application Name=HelpMaster API;"
    strMSG = HMPAPI.StartHelpMasterProAPI() ' Start the API
     
    ' Check for any errors during the startup process.
    ' Any errors will be returned in the string strMSG
    If strMSG <> "" Then
        MsgBox(strMSG)
        HMPAPI.EndHelpMasterProAPI()
        HMPAPI = Nothing
        Exit Sub
    End If
     
     
    ' Load The Site
    Dim mySite As New HelpMasterProAPI.Site
    mySite.Load(612)
     
    ' To List PKIDs of all custom values for Site
    Dim strText As String = ""
    For Each myCustomField As HelpMasterProAPI.CustomField In mySite.CustomFields
       strText += myCustomField.CustomFieldPKID & vbCrLf
    Next myCustomField
    MsgBox(strText)
     
    ' Update a Custom Value For a site
    ' This pkid 5 must be a pkid for a textbox custom field otherwise the appropriate Set__Value function must be called by the Control Type.
    mySite.CustomFields.SetTextBoxValue(5, "123456")
     
    ' Save the Updated Custom Value Back to the Site
    mySite.Save()
     
    mySite.TearDown()
    mySite = Nothing
     
     
    HelpMaster development team.
    Have you seen what's new in v13 yet?
    Drew Goodwin
    New Member
    New Member
    Posts:3
    Points:5


    --
    8/15/2011 10:03 PM

     Hi Scott,

    Thanks for your response. Unfortunately I have run your VB code and get the same result against our database that I was getting with my C# code. When I load up a site that has a number of text box, dropdown box, date and check box custom fields, I get most of the site data, site names, addresses, client links etc, but when I access the CustomFields collection I find it consistently 1 element long where the CustomFieldPKID = 1 and CustomFieldTextBoxValue = "".

    I have written some code that goes straight to the database and can successfully extract the values for these custom fields from tblCustomData_Values_Text for example, and I can also see the custom fields through the standard HMP client. Could there perhaps be an issue with the way the custom fields were created that makes them unavailable to the API now?

    FYI the HelpMasterProAPI version that I am using is 11.0.1.180 and the database I am running against is a v11.0 database that has been upgraded to v11.01.

    Kind regards,
    Drew

    Drew Goodwin
    New Member
    New Member
    Posts:3
    Points:5


    --
    8/15/2011 10:21 PM

     Scott,

    If I run a query like SELECT CustomDataValue FROM dbo.qryCustomData_Site_Text WHERE SitePKID = 1496 AND DefinitionPKID = (select PKID from dbo.qryCustomDataDefinition_Text WHERE EntityType = 2 AND Caption = 'CentreID') against the database I can retrieve the value saved against the site 1496 for custom field CentreID (a simple string of numbers in this instance) and if I open up the site in the HMP client I can see the same string on the Custom tab next to the CentreID label. As mentioned though if I run the following API code:

    ' Connection boiler plate elided
    Dim site As New HelpMasterProAPI.Site
    site.Load(1496)
    Dim strText As String = ""
    For Each myCustomField As HelpMasterProAPI.CustomField In mySite.CustomFields
       strText += myCustomField.CustomFieldPKID & vbCrLf
    Next myCustomField
    MsgBox(strText)
    ' Teardown elided

    I get the string "1" displayed in the message box.

    Kind regards,
    Drew

    Scott Ward
    HelpMaster development team
    Helpdesker
    Helpdesker
    Posts:25
    Points:29


    --
    8/15/2011 11:22 PM
    Hi Drew,
    This behaviour is quite strange, using our test database this all works correctly.

    I'm am logging a HelpMaster Job in to our system for this, so we can track down why this is happening for your database.
    You will recieve an Email with Job reference shortly.
    HelpMaster development team.
    Have you seen what's new in v13 yet?
    You are not authorized to post a reply.


    New version - HelpMaster v24 now available! by Rod Weir in Announcements with 0 replies A new major release of HelpMaster is now available! Read about some of the new features and improvements here:  https://docs.helpmasterpr...-f...

    New version - HelpMaster v23 now available! by Rod Weir in Announcements with 0 replies A new major release of HelpMaster is now available! Read about some of the new features and improvements here:  https://docs.helpmasterpro.com...

    March 2023 v22.7 maintenance release now available by Rod Weir in Announcements with 0 replies A maintenance release for v22.7 HelpMaster is now available! The maintenance release fixes a number of issues that have been reported since the ini...

    July 2022 release now available - New version released! by Rod Weir in Announcements with 0 replies A new feature release of HelpMaster is now available!  v22.7.22 For a list of the major new features of v22, see the new documentation site ht...

    June 2022 v22.2 maintenance release now available by Rod Weir in Announcements with 0 replies A maintenance release for v22.2 HelpMaster is now available! The maintenance release fixes a number of issues that have been reported since the ini...

    RE: Use PowerBI for HelpMaster dashboards by Rod Weir in Reports and reporting Hi SR, Thanks for the post. Yes, the PowerBI reports for HelpMaster have been well received. Download the latest version, from here. https://www...

    RE: Use PowerBI for HelpMaster dashboards by Scenic_Rim_IT in Reports and reporting Hi Rod - just wondering how PowerBI reports are going? Any chance you have a beta/pre-release version we can help test for you?...

    New version - HelpMaster v24 now available! by Rod Weir in Announcements A new major release of HelpMaster is now available! Read about some of the new features and improvements here:  https://docs.helpmasterpr...-f...

    New version - HelpMaster v23 now available! by Rod Weir in Announcements A new major release of HelpMaster is now available! Read about some of the new features and improvements here:  https://docs.helpmasterpro.com...

    March 2023 v22.7 maintenance release now available by Rod Weir in Announcements A maintenance release for v22.7 HelpMaster is now available! The maintenance release fixes a number of issues that have been reported since the ini...

    July 2022 release now available - New version released! by Rod Weir in Announcements A new feature release of HelpMaster is now available!  v22.7.22 For a list of the major new features of v22, see the new documentation site ht...

    June 2022 v22.2 maintenance release now available by Rod Weir in Announcements A maintenance release for v22.2 HelpMaster is now available! The maintenance release fixes a number of issues that have been reported since the ini...

    February 2022 release now available - New version released! by Rod Weir in Announcements A new major release of HelpMaster is now available! For a list of the major new features of v22, see the new documentation site https://docs.helpma...

    November 2021 release now available - New Major Version! by Rod Weir in Announcements A new major release of HelpMaster is now available! For a list of the major new features of v22, see the new documentation site https://docs.helpma...

    May 2021 release now available - New Major Version! by Rod Weir in Announcements A new major release of HelpMaster is now available! For a list of the major new features of v21, see the new documentation site https://docs.helpma...