Using object purposes
About
Purposes allows a developer to filter the results of a search to only include results fit for a particular purpose. This will exclude objects based on built-in business rules, the active date range and access controls. The purposes are particularly useful when building a user interface as you filter search results to only include objects useful in the current context.
Warning
Purposes may be used either via TrimMainObjectSearch.SetPurpose(), or TrimObject.IsValidFor(). There are many purposes which do not get applied when using the TrimMainObjectSearch.SetPurpose, for these you need to to either:
- filter your search results using TrimObject.IsValidFor (or TrimMainObjectSearch.IsValidForPurpose()), or
- display all results and call TrimObject.IsValidFor when the user selects an item and notify them at this point that it is not valid.
Extra information
Some purposes require extra information in the form of either an enum value or an object. For example, find records that are fit for the purpose of containing records of a particular record type. The documentation below lists those purposes that require extra information.
Purpose metadata
For those who need to determine pragmatically which purpose enum and extra objects are available the ObjectDef contains various purpose related properties and methods. The code sample below demsontrates their usage. In addiiton when using the FormDefinition each page item that supports an object lookup contains the properties EditPurpose and EditPurposeExtra.
Code sample - searching
The sample below only lists those Record Types that are valid for creating folders.
{
database.Id = "J1";
database.WorkgroupServerName = "local";
database.Connect();
TrimMainObjectSearch search =
new TrimMainObjectSearch(database,
BaseObjectTypes.RecordType);
search.SelectAll();
foreach (RecordType rec in search)
{
Console.WriteLine(rec.Name);
}
}
Code sample - post search
Many purposes cannot be efficiently applied in a database search and therefore must be run on the results once returned. The code below sets the purpose on the search but then uses TrimMainObjectSearch.IsValidForPurpose() to do the actual filtering. This code will find all Records which are valid containers for a Record of type Document.
{
database.Id = "J1";
database.WorkgroupServerName = "local";
database.Connect();
TrimMainObjectSearch search =
new TrimMainObjectSearch(database,
BaseObjectTypes.Record);
search.SelectAll();
foreach (Record rec in search)
{
if (search.IsValidForPurpose(rec))
{
Console.WriteLine(rec.Title);
}
}
}
Code sample - object definition
This code sample demonstrates how to interrogate an ObjectDef to determine whether it supports purpose filtering and if so which of the purpose enum values support extra information.
{
database.Id = "J1";
database.WorkgroupServerName = "local";
database.Connect();
foreach (ObjectDef objectDef in ObjectDef.SelectAllMainObjects(database))
{
{
Console.WriteLine(objectDef.PurposeEnum);
Console.WriteLine("**** {0} ({1})****", objectDef.Caption, purposeEnum.Caption);
foreach (EnumItem purposeItem in purposeEnum.GetItemArray())
{
if (objectDef.HasExtraPurposeParameter(purposeItem.Value))
{
{
Console.WriteLine("Purpose object type: {0}", objectDef.ExtraPurposeObjectType(purposeItem.Value));
}
else
{
Console.WriteLine("Purpose enum: {0}", extraItem);
}
}
}
}
}
}
List of objects with related purpose enum
HP.HPTRIM.SDK.ActionDef
ActionPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
ActionPurpose.Assigntorecord | | |
ActionPurpose.Attachstep | | ActionDef |
HP.HPTRIM.SDK.Activity
ActivityPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
ActivityPurposes.Browsetemplate | | |
HP.HPTRIM.SDK.AgendaItem
MeetingPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
MeetingPurpose.Addagendaitem | | |
HP.HPTRIM.SDK.AgendaItemType
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.AutoPartRule
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.Classification
ClassificationPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
ClassificationPurpose.Forrecordcreation | | RecordType |
ClassificationPurpose.Recordselection | | |
ClassificationPurpose.Recordtypestart | | |
ClassificationPurpose.Maintain | | |
ClassificationPurpose.Unspecified | | |
ClassificationPurpose.Findcontainerfor | | RecordType |
ClassificationPurpose.Attachdocument | | |
ClassificationPurpose.Editdocument | | |
ClassificationPurpose.Browserecords | | |
ClassificationPurpose.Viewdocument | | |
ClassificationPurpose.Attachrendition | | |
ClassificationPurpose.Relocaterecord | | |
ClassificationPurpose.Defaultcontainer | | RecordType |
ClassificationPurpose.Findalternatecontainerfor | | RecordType |
ClassificationPurpose.Gpssearch | | |
HP.HPTRIM.SDK.DocumentQueue
QueueUsageType
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
QueueUsageType.Unspecified | | |
QueueUsageType.Process | | |
QueueUsageType.Maintain | | |
QueueUsageType.Checkoutto | | |
QueueUsageType.Autoprocess | | |
HP.HPTRIM.SDK.ElectronicStore
StorePurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
StorePurposes.Default | | |
StorePurposes.Replacement | | ElectronicStore |
StorePurposes.Maintain | | |
HP.HPTRIM.SDK.FieldDefinition
FieldPurposeType
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
FieldPurposeType.Useitem | | |
FieldPurposeType.Searchbyitem | | |
FieldPurposeType.Maintainitem | | |
FieldPurposeType.Scheduletriggerdate | | |
HP.HPTRIM.SDK.HtmlLayout
LayoutPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
LayoutPurpose.Maintain | | |
LayoutPurpose.Publish | BaseObjectTypes | |
HP.HPTRIM.SDK.Jurisdiction
JurisdictionPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
JurisdictionPurposes.Maintain | | |
JurisdictionPurposes.Attachtorecord | | |
JurisdictionPurposes.Locationdefault | | |
JurisdictionPurposes.Recordtypedefault | | |
JurisdictionPurposes.Classificationdefault | | |
JurisdictionPurposes.Scheduletrigger | | |
JurisdictionPurposes.Schedulekeepforeverlist | | |
JurisdictionPurposes.Addchildjurisdiction | | |
HP.HPTRIM.SDK.Keyword
KeywordPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
KeywordPurposes.Attach | | |
KeywordPurposes.Attachtitle | | |
KeywordPurposes.Remove | | |
KeywordPurposes.Relate | | Keyword |
KeywordPurposes.Find | | |
KeywordPurposes.Maintain | | |
HP.HPTRIM.SDK.Location
LocationPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
LocationPurpose.Current | | |
LocationPurpose.Contact | | |
LocationPurpose.Home | | |
LocationPurpose.Owner | | |
LocationPurpose.Requester | | |
LocationPurpose.Searchowner | | |
LocationPurpose.Workflowassignee | | |
LocationPurpose.Workflowsupervisor | | |
LocationPurpose.Workflowstatsgroup | | |
LocationPurpose.Mailrecipient | | |
LocationPurpose.Mailrecipientsupervisor | | |
LocationPurpose.Replacementfor | | Location |
LocationPurpose.Addtomemberof | | Location |
LocationPurpose.Addtobossedby | | Location |
LocationPurpose.Addtootherof | | Location |
LocationPurpose.Addtohasmembers | | Location |
LocationPurpose.Addtobossof | | Location |
LocationPurpose.Addtohasothers | | Location |
LocationPurpose.Profileprovider | | |
LocationPurpose.Accesscontrol | | |
LocationPurpose.Addressprovider | | |
LocationPurpose.Maintainlocations | | |
LocationPurpose.Nopurpose | | |
LocationPurpose.Locationdirectory | | |
LocationPurpose.Maintainstaff | | |
LocationPurpose.Maintainexternal | | |
LocationPurpose.Maintaininternal | | |
LocationPurpose.Maintaincontacts | | |
LocationPurpose.Maintainorganizations | | |
LocationPurpose.Maintainunits | | |
LocationPurpose.Maintainpositions | | |
LocationPurpose.Maintaingroups | | |
LocationPurpose.Maintainunknown | | |
LocationPurpose.Addtodelegateof | | Location |
LocationPurpose.Addtohasdelegates | | Location |
LocationPurpose.Maintaincommittees | | |
LocationPurpose.Maintainprojectteams | | |
LocationPurpose.Communicator | | |
LocationPurpose.Maintainvenues | | |
LocationPurpose.Maintainworkgroups | | |
LocationPurpose.Approveagendaitems | | |
LocationPurpose.Meetingvenue | | |
LocationPurpose.Todoassignee | | |
LocationPurpose.Approveclassification | | |
LocationPurpose.Addtoadministeredby | | Location |
LocationPurpose.Addtoadministratorof | | Location |
LocationPurpose.Addcaveatto | | SecurityCaveat |
LocationPurpose.Removecaveatfrom | | SecurityCaveat |
LocationPurpose.Maintainstorageproviders | | |
LocationPurpose.Setdefaultsearchform | | |
LocationPurpose.Archivetransfer | | |
LocationPurpose.Alertsubscriber | | |
LocationPurpose.Emaillinkowner | | |
LocationPurpose.Consignmentarchivist | | |
LocationPurpose.Gpssearch | | |
LocationPurpose.Editor | | |
LocationPurpose.Reviewer | | |
LocationPurpose.Authorizer | | |
HP.HPTRIM.SDK.LookupItem
LookupItemPurposeType
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
LookupItemPurposeType.Useitem | | LookupSet |
LookupItemPurposeType.Searchbyitem | | LookupSet |
LookupItemPurposeType.Maintainitem | | LookupSet |
HP.HPTRIM.SDK.LookupSet
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.Meeting
MeetingPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
MeetingPurpose.Addagendaitem | | |
HP.HPTRIM.SDK.MeetingType
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.MinuteItemType
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.OfflineRecord
OfflineRecordPurpose
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
OfflineRecordPurpose.Attachtorecord | | |
OfflineRecordPurpose.Selectfolder | | |
OfflineRecordPurpose.Cleanupemptyfolder | | |
OfflineRecordPurpose.Manage | | |
HP.HPTRIM.SDK.Record
RecordPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
RecordPurposes.Any | | |
RecordPurposes.Findcontainerfor | | RecordType |
RecordPurposes.Attachdocument | | |
RecordPurposes.Findseries | | |
RecordPurposes.Editdocument | | |
RecordPurposes.Relateto | | Record |
RecordPurposes.Browsingwithinclass | | |
RecordPurposes.Viewdocument | | |
RecordPurposes.Attachrendition | | |
RecordPurposes.Defaultcontainer | | RecordType |
RecordPurposes.Selectclient | | |
RecordPurposes.Selectmatter | | Record |
RecordPurposes.Browseclientmatter | | |
RecordPurposes.Findaltcontainerfor | | RecordType |
RecordPurposes.Gpssearch | | |
RecordPurposes.Findtemplate | | |
HP.HPTRIM.SDK.RecordType
RecordTypeFilter
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
RecordTypeFilter.All | | |
RecordTypeFilter.Electronic | | |
RecordTypeFilter.Allforcreate | | |
RecordTypeFilter.Electronicforcreate | | |
RecordTypeFilter.Allforcreatenomanual | | |
RecordTypeFilter.Electronicforcreatenomanual | | |
RecordTypeFilter.Suitablefornumberingby | | RecordType |
RecordTypeFilter.Forrecordsearch | | |
RecordTypeFilter.Odmacreatedirect | | |
RecordTypeFilter.Foldertocreate | | |
RecordTypeFilter.Foldertocreateelectronic | | |
RecordTypeFilter.Recordwithinclassification | | |
RecordTypeFilter.Recordwithinclassificationelectronic | | |
RecordTypeFilter.Simplewebcreate | | |
RecordTypeFilter.Clientcreate | | |
RecordTypeFilter.Mattercreate | | |
RecordTypeFilter.Matteritemcreate | | |
RecordTypeFilter.Matteritemcreateelectronic | | |
RecordTypeFilter.Sharepointlistitemrecordcreate | | |
RecordTypeFilter.Autosubfoldercreation | | RecordType |
RecordTypeFilter.Autoclassificationsubfolder | | Record |
HP.HPTRIM.SDK.Request
RequestPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
RequestPurposes.Maintain | | |
RequestPurposes.Deleterecordrequest | | Record |
HP.HPTRIM.SDK.SavedSearch
SearchPurposes
HP.HPTRIM.SDK.Schedule
SchedulePurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
SchedulePurposes.Useitem | | |
SchedulePurposes.Searchbyitem | | |
SchedulePurposes.Maintainitem | | |
SchedulePurposes.Replacereferences | | Location |
HP.HPTRIM.SDK.ScheduledTask
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.SearchForm
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.SecurityCaveat
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.SecurityLevel
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |
HP.HPTRIM.SDK.Space
SpacePurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
SpacePurposes.Recordhome | | |
SpacePurposes.Recordhomestrict | | |
SpacePurposes.Searchhome | SpaceRecordsSelection | |
HP.HPTRIM.SDK.UserLabel
LabelPurposes
HP.HPTRIM.SDK.WorkflowTemplate
GenericPurposes
Purpose Enum | Extra Purpose Enum | Extra Purpose Object |
GenericPurposes.Useitem | | |
GenericPurposes.Searchbyitem | | |
GenericPurposes.Maintainitem | | |