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.


    August 2019 release now available by Rod Weir in Announcements with 0 replies A new release of HelpMaster is now available.  This release has some great workflow improvements, new control set fields, a new manager feature, ...

    Allow staff to view all jobs, all skillgroups by Rod Weir in Installation, configuration and upgrading with 0 replies By default, staff members can only view and action jobs that are assigned to the skillgroup(s) that the staff member belong to.  Fine-level contr...

    Building knowledge management and KCS into the workflow by Rod Weir in Using HelpMaster with 0 replies Here's a workflow idea to assist with improved knowledge base articles and knowledge management / KCS As part of a support workflow, build into...

    June 2019 release now available by Rod Weir in Announcements with 0 replies A new release of HelpMaster is now available.  This release builds upon features and stability, particularly in the workflow, and change manageme...

    Workflow email object - email account by Rod Weir in Using HelpMaster with 0 replies The up-coming release of HelpMaster will have a lot of workflow improvements.  One of these is in the email object.  It is now possible to c...

    August 2019 release now available by Rod Weir in Announcements A new release of HelpMaster is now available.  This release has some great workflow improvements, new control set fields, a new manager feature, ...

    Allow staff to view all jobs, all skillgroups by Rod Weir in Installation, configuration and upgrading By default, staff members can only view and action jobs that are assigned to the skillgroup(s) that the staff member belong to.  Fine-level contr...

    Building knowledge management and KCS into the workflow by Rod Weir in Using HelpMaster Here's a workflow idea to assist with improved knowledge base articles and knowledge management / KCS As part of a support workflow, build into...

    June 2019 release now available by Rod Weir in Announcements A new release of HelpMaster is now available.  This release builds upon features and stability, particularly in the workflow, and change manageme...

    Workflow email object - email account by Rod Weir in Using HelpMaster The up-coming release of HelpMaster will have a lot of workflow improvements.  One of these is in the email object.  It is now possible to c...

    Change Management by Rod Weir in Using HelpMaster Change Management in HelpMaster is a relatively new feature that is evolving rapidly.  Based off live-use in small and large departments, our &qu...

    April 2019 release now available by Rod Weir in Announcements A new release of HelpMaster is now available.  This release builds upon features and stability, particularly in the workflow, change management a...

    February 2019 release now available by Rod Weir in Announcements A new release of HelpMaster is now available.  This release builds upon features and stability, particularly in the workflow and web portal. F...

    RE: Job Templates get a new config option for web-based jobs by Rod Weir in Web interface, client self-service and remote access Just further to this topic....if using workflow to log a new job from a job that already contains control sets, and you are using the option to transf...

    November 2018 release now available by Rod Weir in Announcements A new release of HelpMaster is now available.  This release contains lots of fixes, performance tweaks, improved workflow capabilities, improved ...