Record samples
On most methods, you’ll see the parameter named “recId” and “fldId”. The value of these parameters can be a valid record and folder UUID.
Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);Then should login using the method “login”. You can access the “login” method from webservice object “ws” as is shown below:
ws.login(user, password);At this point you can use all the Record methods from “record” class as is shown below:
ws.record.createRecord("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0)Methods
Section titled “Methods”createRecord
Section titled “createRecord”Description:
| Method | Return values | Description |
|---|---|---|
| createRecord(String fldId, String name, String title, long nodeClass) | Record | Creates a new record and returns as a result an object Record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.createRecord(fldId, "PKI-100200", "some title", 0);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getRecordProperties
Section titled “getRecordProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordProperties(String recId) | Record | Returns the record properties. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.record.getRecordProperties("50b7a5b9-89d2-430e-bbc9-6a6e01662a71").path);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}deleteRecord
Section titled “deleteRecord”Description:
| Method | Return values | Description |
|---|---|---|
| deleteRecord(String recId) | void | Deletes a record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.deleteRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}purgeRecord
Section titled “purgeRecord”Description:
| Method | Return values | Description |
|---|---|---|
| purgeRecord(String recId) | void | Records are definitely removed from the repository. |
Usually, you will purge records into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any record from the whole repository.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.purgeRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}renameRecord
Section titled “renameRecord”Description:
| Method | Return values | Description |
|---|---|---|
| renameRecord(String recId, String newName) | void | Renames a record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.renameRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "PKI-100201");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}moveRecord
Section titled “moveRecord”Description:
| Method | Return values | Description |
|---|---|---|
| moveRecord(String recId, String dstId) | void | Moves a record into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.moveRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "055e4384-7c70-4456-b32b-f5a55a79861f");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}copyRecord
Section titled “copyRecord”Description:
| Method | Return values | Description |
|---|---|---|
| copyRecord(String recId, String dstId, String newName) | Record | Copies a record into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path.
When parameter newName value is null, the record will preserve the same name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.copyRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "055e4384-7c70-4456-b32b-f5a55a79861f", "PKI-100200");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}isValidRecord
Section titled “isValidRecord”Description:
| Method | Return values | Description |
|---|---|---|
| isValidRecord(String recId) | Boolean | Returns a boolean that indicates if the node is a record or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine("Is a record:"+ ws.record.isValidRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71").ToString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getRecordChildren
Section titled “getRecordChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordChildren(String fldId) | List |
Returns a list of all records which their parent is fldId |
The parameter fldId can be a folder or a record node.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (Record rec in ws.record.getRecordChildren("055e4384-7c70-4456-b32b-f5a55a79861f")){System.Console.WriteLine(rec);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}lockRecord
Section titled “lockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| lockRecord(String recId) | LockInfo | Locks a record and returns an object with the Lock information |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); LockInfo linf = ws.record.lockRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}unlockRecord
Section titled “unlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| unlockRecord(String recId) | void | Unlocks a locked record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.unlockRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}forceUnlockRecord
Section titled “forceUnlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| forceUnlockRecord(String recId) | void | Unlocks a locked record. |
This method allows unlocking any locked record.
It is not mandatory to execute this action by the same user who previously executed the checkout lock action.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.forceUnlockRecord("50b7a5b9-89d2-430e-bbc9-6a6e01662a71");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setRecordTitle
Section titled “setRecordTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordTitle(String recId, String title) | void | Sets a record title. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.setRecordTitle("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "some title");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getRecordPath
Section titled “getRecordPath”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordPath(String uuid) | String | Converts a record UUID to record path. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); System.Console.WriteLine(ws.record.getRecordPath("50b7a5b9-89d2-430e-bbc9-6a6e01662a71"));}catch (Exception e){ System.Console.WriteLine(e.ToString());}}}}setRecordNodeClass
Section titled “setRecordNodeClass”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordNodeClass(String recId, long ncId) | void | Sets a record node class. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.setRecordNodeClass("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", 0);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setRecordDispositionStage
Section titled “setRecordDispositionStage”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordDispositionStage(String recId, long stage) | void | Set the disposition stage. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.setRecordDispositionStage("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", 1);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setRecordDescription
Section titled “setRecordDescription”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordDescription(String recId, String description) | void | Set the title. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.setRecordDescription("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "some description");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}createWizardRecord
Section titled “createWizardRecord”Description:
| Method | Return values | Description |
|---|---|---|
| createWizardRecord(String uuid, String name, String title, long nodeClass) | WizardNode | Create a record with wizard. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);WizardNode wnode = ws.record.createWizardRecord("f123a950-0329-4d62-8328-0ff500fd42db", "REC-001", "Any title", 0);System.Console.WriteLine(wnode.toString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}createRecordFromTemplate
Section titled “createRecordFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| createRecordFromTemplate(String uuid, String dstPath, bool categories, bool keywords, bool notes, bool propertyGroups, bool security, Dictionary<String, String> properties) |
Record | Creates a new record from the template and returns an object Record. |
The uuid parameter is the template UUID of the record.
The dstPath can be a folder or a record path.
When the template uses metadata groups to fill in fields, then these values are mandatory and must be set into properties parameter.
Example:
using System; using System.Collections.Generic;using System.Linq; using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties.Add("okp:tpl.name", "Some name");DateTime date = DateTime.Now;// Value must be converted to String ISO 8601 compliantproperties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));properties.Add("okp:tpl.language", "[ \"java\" ]");Record record = ws.record.createRecordFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/dst", true, true, false, false, false, properties);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}extendedRecordCopy
Section titled “extendedRecordCopy”Description:
| Method | Return values | Description |
|---|---|---|
| extendedRecordCopy(String uuid, String dstId, String newName, bool categories, bool keywords, bool propertyGroups, bool notes, bool security) | Record | Copies a record with the associated data into some folder or record. |
The values of the dstId parameter should be a folder or record UUID.
When parameter newName value is null, the record will preserve the same name.
Example:
using System; using System.Collections.Generic;using System.Linq; using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);try{ws.login(user, password);ws.record.extendedRecordCopy("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63","new name record", true, true, true, true, true, true);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}forceLockRecord
Section titled “forceLockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| forceLockRecord(String uuid) | LockInfo | Locks a record and returns an object with the Lock information. |
This method allows to lock any record.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);LockInfo lockInfo = ws.record.forceLockRecord("1ec49da9-1746-4875-ae32-9281d7303a62")System.Console.Writeline("Author:" + lockInfo.owner);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}createMissingRecords
Section titled “createMissingRecords”Description:
| Method | Return values | Description |
|---|---|---|
| createMissingRecords(String recPath) | String | Create missing records. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.record.createMissingRecords("/okm:root/rec001/rec0011/rec00111");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}