- Is Field Valid
- Set Field Value
- Get Field Value
- Get Field Count From Def
- All Entity Fields Are Valid
- Get Entity Rule Set Names
- Get Entity Field Values
- Get Field Property
- Set Field Property
- List Properties
- Get Value From Value List
- Loop Through Collection
- Get Entity Display Name
- Get Field Attribute Value
- Create Dictionary
- Load Dictionary
- Get Dictionary Value
- Create Entity And Assign Values
- Is Daylight Saving Time
Is Field Valid
Returns TRUE if the field is valid and FALSE if invalid.
Parameters
- fieldName (Text)
Return Type
Boolean
Script
return Context.Entity.Fields[fieldName].IsValid;
Set Field Value
Sets the value of the supplied field with the supplied value.
Parameters
- fieldName (Text)
- value (Text)
Return Type
None
Script
Context.Entity.Fields[fieldName].Value = value;
Get Field Value
Returns the value of the supplied field.
Parameters
- fieldName (Text)
Return Type
Text
Script
return Context.Entity.Fields[fieldName].Value;
Get Field Count From Def
Returns the count of fields on the current entity.
Parameters
None
Return Type
Integer
Script
return Context.Entity.Fields.Count;
All Entity Fields Are Valid
Returns TRUE if all of the fields on the entity are valid, or FALSE if any are invalid.
Parameters
None
Return Type
Boolean
Script
for (var field in Context.Entity.Fields) { if (field.IsValid == false) return false; } return true;
Get Entity Rule Set Names
Returns a comma separated list of rule set names within the current entity.
Parameters
None
Return Type
Text
Script
var ruleNames = ""; for (var ruleSet in Context.Entity.RuleSets) { if (ruleNames != ""){ ruleNames += ", "; } ruleNames += ruleSet.Name; } return ruleNames;
Get Entity Field Values
Returns a list of field names and values for all fields within the current entity.
Parameters
None
Return Type
Text
Script
var s = Context.Entity.Name + " Field Values: "; for(var field in Context.Entity.Fields) { s = Util.String.Concat(s, field.Name, ": ", field.Value, " "); } return s;
Get Field Property
Returns the value of the supplied property from the supplied field.
Parameters
- field (Text)
- property (Text)
Return Type
Text
Script
if (Context.Entity.Fields[field].ContextProperties.ContainsKey(property)) { return Context.Entity.Fields[field].ContextProperties[property]; } else { return null; }
Set Field Property
Sets the value of the supplied property on the supplied field. If doesn't exist, creates the property.
Parameters
- field (Text)
- property (Text)
- value (Text)
Return Type
None
Script
if (Context.Entity.Fields[field].ContextProperties.ContainsKey(property)) { // update property Context.Entity.Fields[field].ContextProperties[property] = value; } else { // create property Context.Entity.Fields[field].ContextProperties.Add(property, value); }
List Properties
Returns a list of properties and their values on the supplied field.
Parameters
- field (Text)
Return Type
Text
Script
var props = ""; for(var key in Context.Entity.Fields[field].ContextProperties.Keys) { props += key + " " + GetFieldProperty(field, key) + " - "; } return props;
Get Value From Value List
Returns the "value" column from the supplied value list and display value.
Parameters
- displayValue (Text)
- valueListName (Text)
Return Type
Text
Script
function Lookup(DataElements) { var retVal = ""; for(var de in DataElements) { if(de.DataElementType.ToString() == "DataFolder") { retVal = Lookup(de.DataElements) if(retVal != "Not Found") { return retVal; } } if(de.Name == valueListName) { for(var i in de.Items) { if(displayValue == i.DisplayText) { return i.Value; } } } } return "Not found"; } return Lookup(Context.RuleApplication.DataElements);
Loop Through Collection
Returns a list of values for the supplied field on the supplied collection.
Parameters
- collectionName (Text)
- fieldName (Text)
Return Type
Text
Script
var s = ""; var collection = Context.Entity.Collections[collectionName];
if(collection != null) { for(var member in collection) { s = s + member.Fields[fieldName].Value.ToString() + " "; } } return s;
Get Entity Display Name
Returns the entity display name for the supplied entity.
Parameters
- entityID (Text)
Return Type
Text
Script
return Context.GetEntity(entityId).GetDef().DisplayName;
Get Field Attribute Value
Returns the value of the supplied attribute key on the supplied field.
Parameters
- field (Text)
- key (Text)
Return Type
Text
Script
return Context.Entity.Fields[field].GetDef().Attributes[key].ToString();
Create Dictionary
Creates and stores a dictionary with the supplied name for use in lookups.
Parameters
- dictionaryName (Text)
Return Type
None
Script
var dictionary = Util.CreateDictionary(); Context.ContextProperties.Add(dictionaryName,dictionary);
Load Dictionary
Adds a key and value pair to a dictionary.
Parameters
- key (Text)
- value (Text)
- dictionaryName (Text)
Return Type
None
Script
var dictionary = Context.ContextProperties[dictionaryName]; dictionary.Add(key, value);
Get Dictionary Value
Returns the value for the supplied dictionary key.
Parameters
- dictionaryName (Text)
- key (Text)
Return Type
Text
Script
var dictionary = Context.ContextProperties[dictionaryName]; if (dictionary.ContainsKey(key)) { return dictionary[key]; } return "";
Create Entity And Assign Values
Creates a new entity for the supplied entity name and sets the supplied value for the supplied field.
Parameters
- entityName (Text)
- fieldName (Text)
- value (Text)
Return Type
Entity (specific Entity must be specified)
Script
var entity = Context.CreateEntity(entityName); entity.Fields[fieldName].Value = value;
return entity;
Is Daylight Saving Time
Returns TRUE if the supplied date falls within Daylight Saving Time.
Parameters
- checkDate (datetime)
Return Type
Boolean
Script
return checkDate.IsDaylightSavingTime()
Comments
0 comments
Please sign in to leave a comment.