Examples: Create()


The following example is the IG_HomePage_BuildHomePage procedure for the sample integrating application. This procedure creates a new Home Page for the current user when they have chosen the “Lead Generation” role. The ID for this role is passed into the procedure.

The procedure uses the Create() function to create the state object for the Home Page. The Exists() function is used to determine whether the user already has a Home Page defined. If one hasn’t been defined, the AddNew procedure is used to create one. If a Home Page already exists for the user, the SetIndex procedure, Get() function, and SetUserRole procedure are used to retrieve the existing entry. The AddSection and AddSubSection procedures are called to define the Home Page content. Quick Links and Metrics are added. Finally, the Release and Destroy procedures dispose of the Home Page object.

in integer iIndustry;
in integer iUserRole;

local syHomePageState HomePageState;
local long nStatus;
local string sUserID;

if iUserRole = ROLE_LEADGENERATOR then

	sUserID = 'User ID' of globals;

	nStatus = Create(HomePageState, table syHomePage) of form syHomePage;
	if nStatus <> OKAY then
		abort script;
	end if;

	{Add the main record}
	if not Exists(sUserID) of form syHomePage then
		call AddNew of form syHomePage, HomePageState, sUserID, true, true, iUserRole;
		nStatus = Commit(HomePageState) of form syHomePage;
	else
		call SetIndex of form syHomePage, HomePageState, sUserID;
		nStatus = Get(HomePageState,CHG + EQUAL) of form syHomePage;
		if nStatus = OKAY then
			call SetUserRole of form syHomePage, HomePageState, iUserRole;
			nStatus = Commit(HomePageState) of form syHomePage;
		end if;
	end if;

	{Setup the Layout records}
	call AddSection of form syHomePageLayout, sUserID, TODO of form syHomePageMain, DYNAMICS, 1, true;
	call AddSubSection of form syHomePageSubSection, sUserID,TODO of form syHomePageMain, REMINDERS_SUBSECTION of form syHomePageMain, DYNAMICS, true, "";
	call AddSubSection of form syHomePageSubSection, sUserID,TODO of form syHomePageMain, TASKS_SUBSECTION of form syHomePageMain, DYNAMICS, true, "";

	call AddSection of form syHomePageLayout, sUserID, MYREPORTS of form syHomePageMain, DYNAMICS, 1, true;

	call AddSection of form syHomePageLayout, sUserID, QUICKLINKS of form syHomePageMain, DYNAMICS, 2, true;
	call AddSection of form syHomePageLayout, sUserID, METRICS of form syHomePageMain, DYNAMICS, 2, true;

	call AddSection of form syHomePageLayout, sUserID, OUTLOOK of form syHomePageMain, DYNAMICS, 1, false;
	call AddSubSection of form syHomePageSubSection, sUserID,OUTLOOK of form syHomePageMain, INBOX_SUBSECTION of form syHomePageMain, DYNAMICS, false, "";
	call AddSubSection of form syHomePageSubSection, sUserID,OUTLOOK of form syHomePageMain, CALENDAR_SUBSECTION of form syHomePageMain, DYNAMICS, false, str(2);

	{Add the QuickLinks}
	call AddQuickLink of form syHomePageQuickLinks, 
		sUserID,
		QL_COMMAND of form syHomePageMain, 
		resourceid(command IG_Lead_Maintenance of form Command_IG_Sample),
		resourceid(form Command_IG_Sample), 
		IG_PROD_ID, 
		Window_GetMainWindowTitle(IG_PROD_ID, technicalname(form IG_Lead_Maintenance)),
		"";

	{Add Metrics}
	call AddMetric of form syHomePageMetric, 
		sUserID, 
		IG_PROD_ID, 
		METRIC_TOP5LEADS;

	{Perform any cleanup necessary}
	call Release of form syHomePage, HomePageState;
	call Destroy of form syHomePage, HomePageState;

end if;


Documentation Feedback