Difference between revisions of "ResourceTemplatePropertyNumber class"
Nguyenduyan (talk | contribs) (Created page with "{{CGscriptClass_Template |Name=ResourceTemplatePropertyNumber |Description=A numeric property on a resource template |Constructors= {{CGscriptConstructors_Template|Parameters=...") |
Nguyenduyan (talk | contribs) |
||
Line 26: | Line 26: | ||
number folderResourceTemplateRId = 15547989; | number folderResourceTemplateRId = 15547989; | ||
ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ResourceTemplateHelper rth = new ResourceTemplateHelper (); | ||
− | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); | + | FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId); |
− | + | new ResourceTemplatePropertyNumber ("propertyNameTypeNumber",false,"description",folderRT); | |
− | new ResourceTemplatePropertyNumber ("propertyNameTypeNumber",false,"description",folderRT); | ||
− | |||
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); |
− | |||
array arrayProperty = folderRT.Properties; | array arrayProperty = folderRT.Properties; | ||
ResourceTemplatePropertyNumber propertyNumber = arrayProperty[0]; | ResourceTemplatePropertyNumber propertyNumber = arrayProperty[0]; | ||
Line 43: | Line 41: | ||
propertyNumber.MaxValue=1; | propertyNumber.MaxValue=1; | ||
folderRT.SaveProperties(); | folderRT.SaveProperties(); | ||
− | + | </source> | |
− | </source><br/><source lang="javascript"> | + | <br/><source lang="javascript"> |
//Example for deleting a property | //Example for deleting a 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); | ||
− | |||
ResourceTemplatePropertyNumber propertyNumber = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeNumber";}); | ResourceTemplatePropertyNumber propertyNumber = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeNumber";}); | ||
− | propertyNumber.Delete(); | + | propertyNumber.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:37, 5 December 2016
ResourceTemplatePropertyNumber
A numeric 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 numeric property
Methods
Properties
- string Description { get; set; } - Get/set Description
- bool IsDecimal { get; set; } - Get/set IsDecimal
- string Label { get; set; } - Get/set Label
- number MaxValue { get; set; } - Get/set MaxValue, -1 if unset
- number MinValue { get; set; } - Get/set MinValue, -1 if unset
- 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);
new ResourceTemplatePropertyNumber ("propertyNameTypeNumber",false,"description",folderRT);
folderRT.SaveProperties();
//Example for working with existing properies
number folderResourceTemplateRId = 15547989;
ResourceTemplateHelper rth = new ResourceTemplateHelper ();
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId);
array arrayProperty = folderRT.Properties;
ResourceTemplatePropertyNumber propertyNumber = arrayProperty[0];
propertyNumber.IsDecimal=true;
propertyNumber.MaxValue=5;
propertyNumber.MaxValue=1;
folderRT.SaveProperties();
//Example for deleting a property
number folderResourceTemplateRId = 15547989;
ResourceTemplateHelper rth = new ResourceTemplateHelper ();
FolderResourceTemplate folderRT = rth.GetTemplate(folderResourceTemplateRId);
ResourceTemplatePropertyNumber propertyNumber = folderRT.Properties.First(function (object p){return p.Label=="propertyNameTypeNumber";});
propertyNumber.Delete();//if the property is in use, you can not delete and will get error message: Property in use @