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 you should log in using the “login” method. You can access the “login” method from the webservice object “ws” as shown below:
ws.login(user, password);At this point you can use all the Record methods from the “record” class as shown below:
ws.record.create("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0)Methods
Section titled “Methods”create
Section titled “create”Description:
| Method | Return values | Description |
|---|---|---|
| create(String fldId, String name, String title, long nodeClass) | Record | Creates a new record and returns a Record object. |
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.create(fldId, "PKI-100200", "some title", 0); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}createWithPropertyGroup
Section titled “createWithPropertyGroup”Description:
| Method | Return values | Description |
|---|---|---|
| createWithPropertyGroup(String uuid, String name, String title, long nodeClass, String grpName, Dictionary<String, String> properties) | Record | Creates a new record and sets a property group’s properties in the same call. Returns a Record object. |
The parameter uuid should be a valid folder or record UUID.
The grpName should be a valid Metadata group name.
It is not mandatory to set all field values in the properties parameter; only the properties belonging to grpName are applied.
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> props = new Dictionary<String, String>(); props.Add("okp:consulting.name", "test"); ws.record.createWithPropertyGroup(fldId, "PKI-100200", "some title", 0, "okg:consulting", props); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getProperties
Section titled “getProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getProperties(String uuid) | 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.getProperties("50b7a5b9-89d2-430e-bbc9-6a6e01662a71").path); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}delete
Section titled “delete”Description:
| Method | Return values | Description |
|---|---|---|
| delete(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.delete("50b7a5b9-89d2-430e-bbc9-6a6e01662a71"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}Description:
| Method | Return values | Description |
|---|---|---|
| purge(String recId) | void | Records are permanently removed from the repository. |
Usually, you will purge records into /okm:trash/userId - the personal user trash locations - but it is possible to directly purge any record from the entire 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.purge("50b7a5b9-89d2-430e-bbc9-6a6e01662a71"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}rename
Section titled “rename”Description:
| Method | Return values | Description |
|---|---|---|
| rename(String uuid, 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.rename("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "PKI-100201"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}Description:
| Method | Return values | Description |
|---|---|---|
| move(String recId, String dstId) | void | Moves a record into a folder or another 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.move("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "055e4384-7c70-4456-b32b-f5a55a79861f"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}Description:
| Method | Return values | Description |
|---|---|---|
| copy(String recId, String dstId, String newName) | Record | Copies a record into a folder or another record. |
The values of the dstId parameter should be a folder or record UUID or path.
If the newName parameter 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.copy("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "055e4384-7c70-4456-b32b-f5a55a79861f", "PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}isValid
Section titled “isValid”Description:
| Method | Return values | Description |
|---|---|---|
| isValid(String uuid) | Boolean | Returns a boolean that indicates whether the node is 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); System.Console.WriteLine("Is a record:"+ ws.record.isValid("50b7a5b9-89d2-430e-bbc9-6a6e01662a71").ToString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getChildren
Section titled “getChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getChildren(String uuid) | List |
Returns a list of all records whose parent is fldId. |
The parameter uuid 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.getChildren("055e4384-7c70-4456-b32b-f5a55a79861f")) { System.Console.WriteLine(rec); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}setTitle
Section titled “setTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setTitle(String uuid, 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.setTitle("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "some title"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getPath
Section titled “getPath”Description:
| Method | Return values | Description |
|---|---|---|
| getPath(String uuid) | String | Converts a record UUID to a 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.getPath("50b7a5b9-89d2-430e-bbc9-6a6e01662a71")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}setNodeClass
Section titled “setNodeClass”Description:
| Method | Return values | Description |
|---|---|---|
| setNodeClass(String uuid, 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.setNodeClass("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", 0); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}setDispositionStage
Section titled “setDispositionStage”Description:
| Method | Return values | Description |
|---|---|---|
| setDispositionStage(String uuid, long stage) | void | Sets 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.setDispositionStage("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", 1); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}setDescription
Section titled “setDescription”Description:
| Method | Return values | Description |
|---|---|---|
| setDescription(String uuid, String description) | void | Sets 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.setDescription("50b7a5b9-89d2-430e-bbc9-6a6e01662a71", "some description"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}createWizard
Section titled “createWizard”Description:
| Method | Return values | Description |
|---|---|---|
| createWizard(String uuid, String name, String title, long nodeClass) | WizardNode | Creates a record using a 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.createWizard("f123a950-0329-4d62-8328-0ff500fd42db", "REC-001", "Any title", 0); System.Console.WriteLine(wnode.toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}createFromTemplate
Section titled “createFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| createFromTemplate(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 a Record object. |
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, these values are mandatory and must be set in the 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 compliant properties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date)); properties.Add("okp:tpl.language", "[ \"java\" ]"); Record record = ws.record.createFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/dst", true, true, false, true, true, properties); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}extendedCopy
Section titled “extendedCopy”Description:
| Method | Return values | Description |
|---|---|---|
| extendedCopy(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.extendedCopy("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()); } } }}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()); } } }}