Record-level notes

Record-level notes provide the user with a means of attaching comments to a specific record that can be shared with other users. The following illustration shows how a note button appears in a window.

[spacer]

Record-level notes are available on a company-wide basis, meaning that a note applied to a record in company A can be viewed only by users who access that record in company A.

Record-level note buttons are actually made up of two different button fields that indicate whether a note is attached to the current record. The note button with a “clean sheet” should appear if there isn’t a record-level note attached to the record. The note button with the “filled sheet” should appear once the user attaches a note to a record.

[spacer]

Global field

Description

Button

Note Absent Button - Window Area

Indicates the absence of a note for the record.

Note Present Button - Window Area

Indicates the presence of a note for the record.


A note button should appear to the right of the lookup button for a record’s key field. If no lookup button is present, no note button should be present either.

Accessing record-level notes

When the user clicks the note button, one of five note windows should appear, allowing the user to enter a new note or edit an existing one. After the user enters a note and clicks Attach, the note text and its index are stored in the SY_Record_Notes_MSTR table.

You can display this window by opening one of five forms; Form_Note_1, Form_Note_2, Form_Note_3, Form_Note_4 and Form_Note_5. Microsoft Dynamics GP uses multiple forms in order to allow users to enter or edit multiple instances of notes at any given time. When a note is entered or changed and the user clicks Attach, the note ID, date, time and note text and will be stored in the SY_Record_Notes_MSTR table.

Storing record-level notes

Record-level notes are stored in the SY_Record_Notes_MSTR table (SY03900). The layout of this table is shown in the following table.

[spacer]

Field

Control type

Storage size

Description

Note Index

Currency

14

The key field for this table. It stores a unique index for the note record. The developer table must have this field present in order to save and retrieve corresponding note records.

Date

Date

4

Stores the system date when the note record was last updated by the user. This date is displayed in the Note window.

Time

Time

5

Stores the system time when the note record was last updated by the user. This time is displayed in the Note window.

Text Field

Text

0...32,000

Stores the note text entered by the user in the Note window.


Using the note index

To add record-level notes to developer records, you must add the ‘Note Index’ field to the developer table that you want to use record-level notes with. When you save a new developer record with a record-level note, you assign a unique note index to the ‘Note Index’ field in the developer record, then create a new note record in the SY_Record_Notes_MSTR table with the same index.

Retrieving notes

When the developer record is retrieved, its note index is used as a key for the SY_Record_Notes_MSTR table to retrieve its corresponding note record.

Using procedures

The following table explains each of the procedures used to implement record-level notes.

[spacer]

Name

Description

Check_Note_Index

This script ascertains which (if any) of the five note forms is open. If one is open, it determines if the record note displayed is the one for the current developer record.

Get_Next_Form_Note_To_Open

This script ascertains which note form (if any) is currently open and returns an integer indicating the next available note form. There can be a maximum of five note forms open. For example, if Form_Note_1 and Form_Note_3 are open, a 2 will be returned (indicating Form_Note_2).

Check_For_Record_Note

This script reads the SY_Record_Notes_MSTR table based on the note index for the current developer record. If no matching record is found, 0 is returned. If a matching record is found, 1 is returned. The table is closed at the completion of the script.

Get_Next_Note_Index

This script retrieves a note index for a new developer record. This must be stored with the developer record and the note record.

Delete_Record_Note

This script removes a record-level note from the SY_Record_Notes_MSTR table.


Adding record-level notes

To add record-level notes for a window in your application, complete the following steps.

  1. Add a note index to your table.

Add the global field named ‘Note Index’ to the developer table whose records you want to assign notes to. You must use this field to store a unique note index for the developer record; the same index is also stored in the SY_Record_Notes_MSTR table. When a user displays a developer record, you can search the SY_Record_Notes_MSTR table for a note index that matches the index stored with the developer record.

  1. Add note fields to the window.

Open the window’s layout and add the following global fields to the window where you want to assign record-level notes.

[spacer]

Global field

Position

Field properties

Note Absent Button - Window Area

Position this field to the right of the lookup button for the key field.

N/A

Note Present Button - Window Area

Position this field directly over the Note Absent Button - Window Area field.

N/A

Note Index

Position this field off the window layout area.

Visible=False

SetChangeFlag=False

Editable=False

Dummy Record Note Show Hide

Position this field off the window layout area.

Visible=False

SetChangeFlag=False


  1. Add a change script to the Note Absent Button - Window Area button.

This script ascertains whether an existing Note window is open for the current note index. If a Note window is already open for the current record (for instance, if it’s minimized or positioned behind other windows), it’s maximized or brought to the front. If no Note window is open, the first available one is found and opened, and window fields are set to retrieve the note record.

local string l_Note_ID;
local integer l_Form_Number;
local boolean l_Found;

l_Note_ID = 'Lead ID';
if empty(l_Note_ID) then
	warning "Enter a Lead ID prior to attaching a note.";
	focus 'Lead ID';
	abort script;
end if;

{----------------------------------------------------------
This portion of the script checks to see whether a note
form with the current note index is already open.
----------------------------------------------------------}
call Check_Note_Index, 'Note Index', l_Found, l_Form_Number;
if not l_Found then
	call Get_Next_Form_Note_To_Open, l_Form_Number;
	if l_Form_Number = 0 then
		{Too many note forms are open. A message will appear.}
		abort script;
	end if;
end if;

{----------------------------------------------------------
This portion of the script opens the next available notes
form and sets its window fields. There are five forms
available. 
----------------------------------------------------------}
if l_Form_Number = 1 then
	open form Form_Note_1 return to 'Dummy Record Note Show Hide';
	'Record Note' of window Form_Note_1 of form Form_Note_1 = true;
	'Note ID' of window Form_Note_1 of form Form_Note_1 = l_Note_ID;
	'Note Index' of window Form_Note_1 of form Form_Note_1 = 'Note Index';
	if not l_Found then
		run script '(L) Dummy WIN PRE' of window Form_Note_1 of form Form_Note_1;
	end if;

elseif l_Form_Number = 2 then
	open form Form_Note_2 return to 'Dummy Record Note Show Hide';
	'Record Note' of window Form_Note_2 of form Form_Note_2 = true;
	'Note ID' of window Form_Note_2 of form Form_Note_2 = l_Note_ID;
	'Note Index' of window Form_Note_2 of form Form_Note_2 = 'Note Index';
	if not l_Found then
		run script '(L) Dummy WIN PRE' of window Form_Note_2 of form Form_Note_2;
	end if;

elseif l_Form_Number = 3 then
	open form Form_Note_3 return to 'Dummy Record Note Show Hide';
	'Record Note' of window Form_Note_3 of form Form_Note_3 = true;
	'Note ID' of window Form_Note_3 of form Form_Note_3 = l_Note_ID;
	'Note Index' of window Form_Note_3 of form Form_Note_3 = 'Note Index';
	if not l_Found then
		run script '(L) Dummy WIN PRE' of window Form_Note_3 of form Form_Note_3;
	end if;

elseif l_Form_Number = 4 then
	open form Form_Note_4 return to 'Dummy Record Note Show Hide';
	'Record Note' of window Form_Note_4 of form Form_Note_4 =true;
	'Note ID' of window Form_Note_4 of form Form_Note_4 = l_Note_ID;
	'Note Index' of window Form_Note_4 of form Form_Note_4 = 'Note Index';
	if not l_Found then
		run script '(L) Dummy WIN PRE' of window Form_Note_4 of form Form_Note_4;
	end if;

else 
	open form Form_Note_5 return to 'Dummy Record Note Show Hide';
	'Record Note' of window Form_Note_5 of form Form_Note_5 = true;
	'Note ID' of window Form_Note_5 of form Form_Note_5 = l_Note_ID;
	'Note Index' of window Form_Note_5 of form Form_Note_5 = 'Note Index';
	if not l_Found then
		run script '(L) Dummy WIN PRE' of window Form_Note_5 of form Form_Note_5;
	end if;
end if;

  1. Add a change script to the Note Present Button - Window Area field.

This script attempts to display the note currently applied to the record and runs only if a note is attached to the current record, and the ‘Note Present Button - Window Area’ field is displayed (see the example in step 5).

run script 'Note Absent Button - Window Area';

  1. Add a change script to the Dummy Record Note Show Hide field.

This script runs when the user initially displays the record (see step 6). The procedure Check_For_Record_Note attempts to read the SY_Record_Notes_MSTR table based on the note index for the displayed record. If a note record is found, this script sets the ‘Dummy Record Note Show Hide’ field to 1 to display the button fields appropriately.

call Check_For_Record_Note, 'Note Index', 'Dummy Record Note Show Hide';
if 'Dummy Record Note Show Hide' = 1 then
	hide 'Note Absent Button - Window Area';
	show 'Note Present Button - Window Area';
else
	hide 'Note Present Button - Window Area';
	show 'Note Absent Button - Window Area';
end if;

  1. Modify the change script for the window’s key field.

This script retrieves an existing developer record; if there is no associated note index for the developer record, one is assigned to the record using the Get_Next_Note_Index procedure. If a note index exists, run the script for the ‘Dummy Record Note Show Hide’ field is run to ascertain whether a note record exists for the developer record.

'Lead ID' of table IG_Leads_MSTR = 'Lead ID' of window 'Lead Maintenance';
release table IG_Leads_MSTR;
change table IG_Leads_MSTR by IG_Leads_MSTR_Key1;

if err() = OKAY then
	if empty ('Note Index' of table IG_Leads_MSTR) then
		{Retrieve a new note index and assign it.}
		call Get_Next_Note_Index, 'Note Index' of table IG_Leads_MSTR;
		save table IG_Leads_MSTR;
		change table IG_Leads_MSTR;
	end if;
	copy from table IG_Leads_MSTR;
	clear changes form IG_Lead_Maintenance;
	enable 'Delete Button';
	{Check to see whether the lead record has a note attached.}
	run script 'Dummy Record Note Show Hide';
end if;
lock 'Lead ID';

  1. Modify the Delete button change script.

This script calls the Delete_Record_Note procedure, which deletes the note record associated with current note index from the SY_Record_Notes_MSTR table.

if ask("Delete this lead record?", "Cancel", "Delete", "") = ASKBUTTON2 then
	{The user chose to delete the record.}
	remove table IG_Leads_MSTR;
	call Delete_Record_Note,'Note Index';
	restart form;
end if;

  1. Add a window pre script.

In this script, the show field and hide field statements ensure that the note button will display a “clean sheet” when the form is opened or restarted.

show 'Note Absent Button - Window Area';
hide 'Note Present Button - Window Area';


Documentation Feedback