Entity

  • Updated

An instance of an authored Entity whose state is maintained by the RuleSession.

getField(fieldName) Returns: Field

Parameters:

fieldName

Type: string

The name of the Field to return

Description:

Returns a Field object of the specified name

Code Sample:

var session = inrule.createRuleSession();
var entity1 = session.createEntity("Entity1"); 
var field = entity1.getField("Field1");

 

getCollection(collection Name) Returns: Collection

Parameters:

collectionName

Type: string

The name of the Collection to return

Description:

Returns a Collection of the specified name

Code Sample:

var session = inrule.createRuleSession();
var entity1 = session.createEntity("Entity1"); 
var field = entity1.getCollection("Collection1");

 

getValue() Returns: object

Description:

Returns the object bound to the current Entity

Code Sample:

var session = inrule.createRuleSession(); 
var boundValue = {"FirstName": "John"}; var entity = session.createEntity("Entity1", boundValue);
var entityValue = entity.getValue(); // entityValue and boundValue are identical

 

getName() Returns: string

Description:

Returns a string of the Entity's name

Code Sample:

var session = inrule.createRuleSession(); 
var entity = session.createEntity("Entity1"); var entityName = entity.getName(); // entityName is "Entity1";

 

getElementId() Returns: string

Description:

The element identifier which uniquely identifies this Entity within its RuleSession

Code Sample:

var session = inrule.createRuleSession(); 
var entity = session.createEntity("Entity1"); var entityId = entity.getElementId(); // entityId is now "Entity1:1"

 

isValid() Returns: bool

Description:

Returns a boolean indicating whether or not the current Entity is valid based on the rules that were executed. If rules have not been applied, this will always return True.

Code Sample:

var session = inrule.createRuleSession();
var entity1 = session.createEntity("Entity1"); 
// Assuming Entity1 has a Rule Set that marks it as Invalid // entity1.isValid() returns True session.applyRules(function(log){ // entity1.isValid() returns False });

 

executeRuleSet(name, arguments, callback) Returns: void

Parameters:

name

Type: string

The name of the RuleSet to execute

 

arguments

Type: Array of object

An Array of values to pass to the RuleSet. The values are bound to the arguments by ordinal positioning. If an argument is an Entity, the value passed to it will be used as the Entity's bound value. If the RuleSet does not have parameters, pass an empty array.

 

callback

Type: function(log)

A JavaScript function accepting a RuleExecutionLog object as its parameter

Description:

Executes the Rule Set with the specified name on the Entity. If arguments are provided they are passed to the Rule Set.

Code Sample:

var session = inrule.createRuleSession(); 
var entity = session.createEntity("Entity1"); entity.executeRuleSet("RuleSet1", [1, "value"], function(log){ // Code that checks the Execution Log });

 

metadata Returns: AuthoringMetadata

Description:

Returns an AuthoringMetadata object for the Rule Application

Code Sample:

var session = inrule.createRuleSession(); 
var entity = session.createEntity("Entity1"); var displayName = entity.metadata.displayName;

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.