- 03 Jun 2022
- 3 Minutes to read
- Print
- DarkLight
Records Actions
- Updated on 03 Jun 2022
- 3 Minutes to read
- Print
- DarkLight
addRecordField
Add record field (with no values) if it doesn't already exist.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
Note
myRecord = createRecord()
addRecordField(myRecord, "sn")
addRecordFieldValue
Add record field value.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
value* | text, expression, variable | the value to add to the field |
ignoreCase | boolean, expression, variable | ignore the case of the value when deciding if a duplicate (default: false) |
Note
myRecord = createRecord()
addRecordField(myRecord, "registeredCourses")
addRecordFieldValue(myRecord, "registeredCourses", "English I")
addRecordFieldValue(myRecord, "registeredCourses", "Algebra I")
addRecordFieldValue(myRecord, "registeredCourses", "Band")
addRecordFieldValues
Add record field values.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
values* | text, expression, variable | An array containing the values to add to the field |
ignoreCase | boolean, expression, variable | ignore the case of the value when deciding if a duplicate (default: false) |
Note
myRecord = createRecord()
addRecordField(myRecord, "registeredCourses")
addRecordFieldValue(myRecord, "registeredCourses", "English I")
addRecordFieldValue(myRecord, "registeredCourses", "Algebra I")
addRecordFieldValue(myRecord, "registeredCourses", "Band")
addRecordFieldValues(myRecord, "registeredCourses",
["Physical Science","Physical Ed"])
clearRecordFieldValues
Clear record field values.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
Note
myRecord = createRecord()
addRecordField(myRecord, "registeredCourses")
addRecordFieldValue(myRecord, "registeredCourses", "English I")
addRecordFieldValue(myRecord, "registeredCourses", "Algebra I")
addRecordFieldValue(myRecord, "registeredCourses", "Band")
clearRecordFieldValues(myRecord, "registeredCourses")
copyRecord
Make a duplicate copy of a record.
Property | Value | Description |
record* | expression, variable | the record to copy |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
myRecord = createRecord()
addRecordField(myRecord, "registeredCourses")
addRecordFieldValue(myRecord, "registeredCourses", "English I")
addRecordFieldValue(myRecord, "registeredCourses", "Algebra I")
addRecordFieldValue(myRecord, "registeredCourses", "Band")
newRecord = copyRecord(myRecord)
copyRecordField
Copy a record field.
Property | Value | Description |
record* | expression, variable | the record |
oldField* | text, expression, variable | the field name of the original field. |
newField* | text, expression, variable | the field name of the new field. |
Note
myRecord = createRecord()
addRecordField(myRecord, "groupMembership")
addRecordFieldValue(myRecord, "groupMembership",
"cn=AllStaff,ou=groups,o=data")
addRecordFieldValue(myRecord, "groupMembership",
"cn=AllTeachers,ou=groups,o=data")
copyRecordField(myRecord,"groupMembership","securityEquals")
copyRecordFields
Copy fields from one record to another.
Property | Value | Description |
srcRecord* | expression, variable | the source record |
destRecord* | expression, variable | the destination record |
fields | text, expression, variable | comma separated list of fields to copy (default: all fields) |
Note
myRecord = createRecord()
addRecordField(myRecord, "groupMembership")
addRecordFieldValue(myRecord, "groupMembership",
"cn=AllStaff,ou=groups,o=data")
addRecordFieldValue(myRecord, "groupMembership",
"cn=AllTeachers,ou=groups,o=data")
copyRecordField(myRecord,"groupMembership","securityEquals")
newRecord = createRecord()
copyRecordFields(myRecord,newRecord,["groupMembership","securityEquals"])
createRecord
Create a new record object. A record is made of of fields, each of which may have 0 or more values.
Property | Value | Description |
caseSensitiveNames | boolean, expression, variable | field names are case-insensitive (default: false) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
user = createRecord()
setRecordFieldValue(user,"objectclass","inetOrgPerson")
createRecordFromObject
Create a new record object from an ECMAScript object.
Property | Value | Description |
seed | expression, variable | Seed object that provides the initial fields and values for the Record |
caseSensitiveNames | boolean, expression, variable | field names are case-insensitive (default: false) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
record = createRecordFromObject({sn: "John", givenName: "Doe"})
createRecordFromXML
Create a new record object from an XML object using this
Property | Value | Description |
xml | expression, variable | XML object that provides the initial fields and values for the Record |
excludeAttrs | boolean, expression, variable | exclude all XML attributes (default: false) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
xml = <data>
<sn>John</sn>
<givenName>Doe</givenName>
</data>
record = createRecordFromXML(xml)
filterRecordFields
Filter record fields.
Property | Value | Description |
record* | expression, variable | the record |
fields* | text, expression, variable | comma separated list (or an array) of fields to keep - all others will be removed. |
Note
user = createRecord()
addRecordField(user,"objectclass")
addRecordField(user,"sn")
addRecordField(user,"givenName")
addRecordField(user,"ssn")
filterRecordFields(user,"objectclass,sn,givenName")
getRecordFieldNames
Get all record field names.
Property | Value | Description |
record* | expression, variable | the record |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
fieldNames = getRecordFieldNames(record)
forEach(fieldName, fieldNames) {
log(fieldName + ": " + record.fieldName
}
getRecordFieldValue
Get the first value of a record field.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
user = createRecord()
addRecordFieldValue(user,"objectclass","inetOrgPerson")
addRecordFieldValue(user,"objectclass","Top")
addRecordFieldValue(user,"objectclass","Person")
objectClass = getRecordFieldValue(user,"objectclass")
getRecordFieldValues
Get all values of record field.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
user = createRecord()
addRecordFieldValue(user,"objectclass","inetOrgPerson")
addRecordFieldValue(user,"objectclass","Top")
addRecordFieldValue(user,"objectclass","Person")
objectClasses = getRecordFieldValues(user,"objectclass")
hasRecordField
Check if record has a field.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
user = createRecord()
addRecordFieldValue(user,"objectclass","inetOrgPerson")
addRecordFieldValue(user,"objectclass","Top")
addRecordFieldValue(user,"objectclass","Person")
hasObjectClass = hasRecordField(user,"objectclass")
hasGivenName = hasRecordField(user,"givenName")
# Should return "We have class!"
if(hasObjectClass) {
log("We have class!")
} else {
}
if(hasGivenName) {
log("We have a name!")
} else {
}
hasRecordFieldValue
Check if record field has a given value.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
value* | text, expression, variable | the value to check. |
ignoreCase | boolean, expression, variable | ignore the case of the value when comparing (default: false) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
student = createRecord()
addRecordFieldValue(student ,"course","english")
addRecordFieldValue(student ,"course","science")
addRecordFieldValue(student ,"course","art")
hasEnglish = hasRecordFieldValue(user,"course","english")
hasMath = hasRecordFieldValue(user,"course","math")
# Should return "Y,N"
if(hasEnglish) {
log("Y")
} else {
}
if(hasMath) {
log("N")
} else {
}
recordEquals
Compare two records for equality.
Property | Value | Description |
record1* | expression, variable | the first record |
record2* | expression, variable | the second record |
fields | expression,text,variable | comma separated list of fields to compare (default: all fields) |
ignoreCase | boolean, expression, variable | ignore the case of the value when comparing (default: false) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Note
inputRecord = getNextTextInputRecord(input)
existingRecord = getADRecord(sessionAD, inputRecord['@dn'])
if(existingRecord) {
same = recordEquals(inputRecord, existingRecord)
if(!same) {
saveADRecord(inputRecord)
}
} else {
}
removeRecordField
Remove record field.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
Note
user = createRecord()
addRecordField(user,"objectclass")
addRecordField(user,"sn")
addRecordField(user,"givenName")
addRecordField(user,"ssn")
removeRecordField(user,"ssn")
removeRecordFields
Remove record fields.
Property | Value | Description |
record* | expression, variable | the record |
fields* | text, expression, variable | comma separated list of fields to remove |
Note
user = createRecord()
addRecordField(user,"objectclass")
addRecordField(user,"sn")
addRecordField(user,"givenName")
addRecordField(user,"ssn")
removeRecordField(user,"ssn,objectclass")
removeRecordFieldValue
Remove record field value.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
value* | text, expression, variable | the value to remove from the field |
ignoreCase | boolean, expression, variable | ignore the case of the value when comparing (default: false) |
Note
student = createRecord()
addRecordFieldValue(student ,"course","english")
addRecordFieldValue(student ,"course","science")
addRecordFieldValue(student ,"course","art")
removeRecordFieldValue(user,"course","english")
removeRecordFieldValues
Remove record field values.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
values* | text, expression, variable | An array containing the values to remove from the field |
ignoreCase | boolean, expression, variable | ignore the case of the value when comparing (default: false) |
Note
student = createRecord()
addRecordFieldValue(student ,"course","english")
addRecordFieldValue(student ,"course","science")
addRecordFieldValue(student ,"course","art")
removeRecordFieldValues(user,"course",["english","art"])
renameRecordField
Rename a record field.
Property | Value | Description |
record* | expression, variable | the record |
oldField* | text, expression, variable | the original field name |
newField* | text, expression, variable | the new field name |
Note
user = createRecord()
addRecordField(user,"objectclass")
addRecordField(user,"sn")
addRecordField(user,"givenName")
addRecordField(user,"ssn")
renameRecordField(user,"ssn","workforceID")
renameRecordFields
Rename fields within a record.
Property | Value | Description |
record* | expression, variable | the record |
oldFields* | text, expression, variable | comma separated list of the original field names |
newFields* | text, expression, variable | comma separated list of the new field names |
Note
user = createRecord()
addRecordField(user,"objectclass")
addRecordField(user,"Surname")
addRecordField(user,"Given Name")
addRecordField(user,"ssn")
renameRecordFields(user,["Surname","Given Name","ssn"],
["sn","givenName","workforceID"])
setRecordFieldValue
Set record field to a value.
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
value* | text, expression, variable | the field value |
Note
user = createRecord()
setRecordFieldValue(user,"objectclass","Top")
setRecordFieldValue(user,"objectclass","inetOrgPerson")
setRecordFieldValues
Property | Value | Description |
record* | expression, variable | the record |
field* | text, expression, variable | the field name |
values* | text, expression, variable | An array containing the values to set to the field |
Note
student = createRecord()
setRecordFieldValues(student,"course",["english","math","science"])