Difference between revisions of "ResourceTemplatePropertyResource class"
Nguyenduyan (talk | contribs) (Created page with "{{CGscriptClass_Template |Name=ResourceTemplatePropertyResource |Description=A Resource property on a resource template |Constructors= {{CGscriptConstructors_Template|Paramete...") |
Nguyenduyan (talk | contribs) |
||
Line 28: | Line 28: | ||
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | ||
}} | }} | ||
− | |||
− | |||
=== <span style="color:#DF8621">'''Examples'''</span> === | === <span style="color:#DF8621">'''Examples'''</span> === | ||
Line 38: | Line 36: | ||
ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ||
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); | ||
− | |||
ResourceTemplatePropertyResource propertyResource = new ResourceTemplatePropertyResource ("propertyNameTypeResource", false, "", folderRT); | ResourceTemplatePropertyResource propertyResource = new ResourceTemplatePropertyResource ("propertyNameTypeResource", false, "", folderRT); | ||
− | propertyResource.AddAllowedResourceType(Resource_Type_Folder,{2071,15504791}); | + | propertyResource.AddAllowedResourceType(Resource_Type_Folder,{2071,15504791}); |
− | |||
folderRT.SaveProperties(); | folderRT.SaveProperties(); | ||
− | </source><br/><source lang="javascript"> | + | </source> |
+ | <br/><source lang="javascript"> | ||
//Example for working with existing properies | //Example for working with existing properies | ||
− | |||
number folderResourceTemplateRId = 15547989; | number folderResourceTemplateRId = 15547989; | ||
ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ||
− | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); | + | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); |
− | |||
ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";}); | ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";}); | ||
propertyResource.RemoveAllowedResourceType(Resource_Type_Report); | propertyResource.RemoveAllowedResourceType(Resource_Type_Report); | ||
− | |||
propertyResource.AddAllowedResourceType(Resource_Type_Folder); | propertyResource.AddAllowedResourceType(Resource_Type_Folder); | ||
propertyResource.AddAllowedResourceType(Resource_Type_Project,{4624,2070}); | propertyResource.AddAllowedResourceType(Resource_Type_Project,{4624,2070}); | ||
− | |||
folderRT.SaveProperties(); | folderRT.SaveProperties(); | ||
print(propertyResource.AllowsResourceType(Resource_Type_Project));//return array of ResourceId of project template {2070,4624} | print(propertyResource.AllowsResourceType(Resource_Type_Project));//return array of ResourceId of project template {2070,4624} | ||
− | + | </source> | |
− | </source><br/><source lang="javascript"> | + | <br/><source lang="javascript"> |
//Example for deleting property | //Example for deleting property | ||
− | |||
number folderResourceTemplateRId = 15547989; | number folderResourceTemplateRId = 15547989; | ||
ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ||
− | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); | + | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); |
− | |||
ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";}); | ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";}); | ||
− | propertyResource.Delete(); | + | propertyResource.Delete();//if the property is in use, you can not delete and will get error message: Property in use @ |
− | |||
</source> | </source> |
Revision as of 08:38, 5 December 2016
ResourceTemplatePropertyResource
A Resource property on a resource template
Constructors
- (string label "Set label", bool required "Set required", string description "Set description", ResourceTemplate resourceTemplate "ResourceTemplate property gets added to") - Create new Resource property
Methods
- Empty AddAllowedResourceType(int resourceType "ResourceType") - Set all templates of given resource type allowed
- Empty AddAllowedResourceType(int resourceType "ResourceType", array specificResourceTemplates "Array of resource template resource ids") - Set specific templates of given resource type allowed
- Array of number AllowsResourceType(int resourceType "ResourceType") - Get allowed resource templates resource ids for a given resource type. Empty means none, array with no entries means all.
- Empty Delete() - Delete the property
- Empty RemoveAllowedResourceType(int resourceType "ResourceType") - Set all templates of given resource type disallowed
- string ToString() - The string representation of the object.
Properties
- string Description { get; set; } - Get/set Description
- string Label { get; set; } - Get/set Label
- string ObjectTypeName { get; } - The name of the type of object.
- bool Required { get; set; } - Get/set Required
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
//Example for creating new properties
number folderResourceTemplateRId = 15547989;
ResourceTemplateHelper rth = new ResourceTemplateHelper ();
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId);
ResourceTemplatePropertyResource propertyResource = new ResourceTemplatePropertyResource ("propertyNameTypeResource", false, "", folderRT);
propertyResource.AddAllowedResourceType(Resource_Type_Folder,{2071,15504791});
folderRT.SaveProperties();
//Example for working with existing properies
number folderResourceTemplateRId = 15547989;
ResourceTemplateHelper rth = new ResourceTemplateHelper ();
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId);
ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";});
propertyResource.RemoveAllowedResourceType(Resource_Type_Report);
propertyResource.AddAllowedResourceType(Resource_Type_Folder);
propertyResource.AddAllowedResourceType(Resource_Type_Project,{4624,2070});
folderRT.SaveProperties();
print(propertyResource.AllowsResourceType(Resource_Type_Project));//return array of ResourceId of project template {2070,4624}
//Example for deleting property
number folderResourceTemplateRId = 15547989;
ResourceTemplateHelper rth = new ResourceTemplateHelper ();
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId);
ResourceTemplatePropertyResource propertyResource = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeResource";});
propertyResource.Delete();//if the property is in use, you can not delete and will get error message: Property in use @