PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08/16/2011 12:22 AM 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


--
08/12/2011 1: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


    --
    08/15/2011 9: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


    --
    08/15/2011 11: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


    --
    08/15/2011 11: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


    --
    08/16/2011 12:22 AM
    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 employee on-boarding workflow using new workflow objects by Rod Weir in Using HelpMaster with 0 replies As the workflow capabilities of HelpMaster continue to improve, one of the things that we've been seeing from users of HelpMaster is building proc...

    Maintenance release of HelpMaster, v17.20.14 is now available by Rod Weir in Announcements with 0 replies A new release for v17 is now available.   This release fixes a number of issues for version 17 as well as new and enhanced features. &...

    Video settings on 4K monitors and/or high DPI settings by Rod Weir in Bugs!!! with 0 replies We've recently been getting bug reports of not being able to select items from drop-down boxes on the job screen (and others) when using high-res ...

    Faster entity search screens coming by Rod Weir in Using HelpMaster with 0 replies Next release of HelpMaster will feature faster entity search screens (clients, sites, assets, all templates etc).  We've re-factored a lot of...

    Email Manager and Priority Manager services by Josh B in Bugs!!! with 1 replies Recently we have had a number of problems with the Email Manager and Priority Manager.  We have worked through all of these issues on a case-by-c...

    New employee on-boarding workflow using new workflow objects by Rod Weir in Using HelpMaster As the workflow capabilities of HelpMaster continue to improve, one of the things that we've been seeing from users of HelpMaster is building proc...

    Maintenance release of HelpMaster, v17.20.14 is now available by Rod Weir in Announcements A new release for v17 is now available.   This release fixes a number of issues for version 17 as well as new and enhanced features. &...

    Video settings on 4K monitors and/or high DPI settings by Rod Weir in Bugs!!! We've recently been getting bug reports of not being able to select items from drop-down boxes on the job screen (and others) when using high-res ...

    Faster entity search screens coming by Rod Weir in Using HelpMaster Next release of HelpMaster will feature faster entity search screens (clients, sites, assets, all templates etc).  We've re-factored a lot of...

    RE: Email Manager and Priority Manager services by Rod Weir in Bugs!!! Hi Josh, Thanks for reporting this and for assisting the dev team off-line to diagnose this issue. We've been working on the code and have foun...

    Email Manager and Priority Manager services by Josh B in Bugs!!! Recently we have had a number of problems with the Email Manager and Priority Manager.  We have worked through all of these issues on a case-by-c...

    Updating custom Crystal Reports to work with UTC dates by Rod Weir in Reports and reporting HelpMaster v12 changes the way date data is stored in the database.  If you have created custom Crystal Reports (or other reports in other soluti...

    Maintenance release of HelpMaster, v17.16.28 is now available by Rod Weir in Announcements This release fixes a number of issues for version 17. For a detailed list of fixes, refer to the version history.   For a list of the major...

    Categories for templates - Job, Action, Email by Rod Weir in Using HelpMaster Configuring HelpMaster is an on-going task that requires a good understanding of the business and the processes you're working with.  To assi...

    RE: Emails marked as "read" not being picked up by Email Manager by Rod Weir in Email Manager Just to update this old post. This was done for the version 16 release of HelpMaster. http://www.helpmasterpro.com/Support/Updates-and-Service-Packs...