Login to participate
Endpoint Management & Virtualization ArticlesRSS

Adding a Checkbox to a Custom Helpdesk Page

razell's picture

Here are the steps I worked out to add a custom checkbox to a form on a Helpdesk page. Hopefully it will help someone else looking for a way to add similar functionality to their forms.

  • Run SQL server
  • Select Altiris database Incident
  • Run this SQL :
    ALTER TABLE workitem ADD checkbox1 nchar(1) NOT NULL DEFAULT
    (N'')
    EXEC sp_addviewdef N'workitem_only_view', N'workitem.checkbox1
    AS workitem_checkbox1', N''
    EXEC sp_createHDDview 'workitem_only_view', 'workitem'
    EXEC sp_createHDDview 'workitem_detail_view', 'workitem_only_view'
    if exists (select * from sysobjects where id 
    =object_id(N'[dbo].[workitem_current_view]') and OBJECTPROPERTY(id,N'IsView') = 
    0)drop view [dbo].[workitem_current_view]
    
    

    (Replace all instances of the "checkbox1" with the name of your field.)

  • Run this sql:
    CREATE VIEW dbo.workitem_current_view AS SELECT workitem_detail_view.* FROM 
    workitem_detail_view WHERE (workitem_is_last = N'1')
    
    

Modify the Worker Page in View Mode

  • Open your "customworkitemview.ascx"
  • Find the line with:
    </script> 
    <aw:layout id="loItem" runat="server" HorizontalAlign="Justify" Width="100%" 
    columns="4" ItemDataSourceName="WorkItem"...
    
    
  • Paste this before:
    Protected Function IsYes(x) as String
    'converts the value stored for initials and other yes/no options from int to a boolean. 
    If x = "1" then
    return "Ok"
    Else 
    return "Nok"
    End If
    End Function
    
    
  • Find the line with:
    <aw:Label id="lblType" runat="server" ColSpan="4" 
    ItemDataField="workitem_type_lookup_value" label="sidLblType"></aw:Label>...
    
    
  • Paste this before:
    <aw:Label id="cbcheckbox1Yes" ItemDataField="workitem_checkbox1" width="80px" 
    runat="server" visible="false" /></aw:Label>	
    <aw:Label id="lblcheckbox1" ColSpan="4" runat="server" label="checkbox1" runat="server"
    Text="<%# IsYes(cbcheckbox1Yes.text) %>" CssClass="clsToolbar" width="30px"/>
    
    

Modify the Worker Page in Edit Mode

  • Open your "customworkitemeditgeneral.ascx"
  • Find the line with:
    <aw:DropDownList id="ddlPriority" runat="server" Width="100%"
    ItemDataField="workitem_priority_lookup_id" Label="sidLblPriority" DataTextField="value"
    DataValueField="id" DataSourceName="Priorities" currentValue="True"></aw:DropDownList>...
    
    
  • Paste this before:
    <aw:CheckBox id="cbcheckbox1" runat="server" label="test checkbox1:" ColSpan="4"
    ItemDataField="workitem_checkbox1" valuechecked="1" valueunchecked="0" text="<-- this is an example1"></aw:CheckBox>
    

Results (with 2 checkboxes)

Edit mode

View mode

xmoreland's picture

Nice

This is something that I could see coming in handy as we plan our implimentation...thanks!

dpeluso's picture

Remove checkbox1 from workitem.

Hi all,
Could someone please explain to me how I can remove the checkbox1 field from the workitem table? Seems a little harder than just deleting the field and re-running the 'sp_createHDDview' procedure.
Thanks in advance, Daniel

dbush's picture

Almost...

Hey Daniel,

Cheers to Australia. You're actually about right. Only thing you're missing is the second step of the process adds a line to the view_def table to be used when the sp_createHDDview procedure runs. I usually take the most direct way and edit this table directly, find the row for the 'checkbox1' field and delete it. Then re-run the stored procedure and you should be good to go.

David

David Falcon's picture

response

hi dpeluso-

you should just have to remove the column from the workitem table, then remove the entry from the view_def table. once you have removed from both of those, re-run the stored procedure to recreate the view. you should be good to go after that. don't forget to remove them from any templates that you added them to.

Hubert Kacprzak's picture

What about log?

Everything fine but what about log?
When I change only the checkbox in the incident the message in the history is: "This incident was saved, but there were no changes detected."

Shouldn't it be logged by standard? I can write a incident rule to add a comment but it should also check if other fields were changed or not etc...

Lucke's picture

Good Article

It is just what I´m looking for!!
Thanks!!