Departments created and assigned via API

Posted by Rollbase User on 30-Jan-2012 17:45

Maybe this is meant to be or I am missing something, but I have noticed that when creating Departments (via query api) and assigning them, the hierarchical permissions don't always work if you don't put something in the Department Code field (deptCode). Also, that something cannot have spaces in it. For example, I can create new department without deptCode set, assign it to a record: a user whose department is higher up the tree from the new department cannot see it. If I edit the new department, add something to Department Code field, then the user can view it.

All Replies

Posted by Admin on 30-Jan-2012 17:53

Please attach snippet of your code - that would help understand the problem.



Posted by Admin on 30-Jan-2012 18:08

Given this department hierarchy:



1. TopLevelDepartment

1.1. 2ndLevelDepartment_1

1.2. 2ndLevelDepartment_2

1.2.1. 3rdLevelDepartment_1





Create the department like this (I am using an object script trigger):



var deptId = rbv_api.createRecord("$ORG_DEPT", {

name : "NewDept",

parentId : 2ndLevelDepartment_2

});



//Set an object record's LDF as per:

rbv_api.updateRecord("some_object", "{!id}", {

locationId : 12345678,

departmentId : deptId

});







A user assigned group permissions of

{

locationId : 12345678,

departmentId : TopLevelDepartment

}



cannot see the object record. If I then go and edit the new department created and add, for example "New_Dept", into the Department Code field as the only edit (ie leave Department unchanged), the user can then see the record.



Also, and I haven't tested this extensively, but Department Code cannot contain spaces or the user still cannot see it.

Posted by Admin on 30-Jan-2012 18:37

I do not see where you're using Department Code - I see Department ID instead. Code is for convenience only.



LDF issues are complex. I would recommend you setup LDF manually first (without API) and make sure it works for you as you expected. Please use "LDF Filter" field to debug LDF-related permissions.

Posted by Admin on 30-Jan-2012 18:44

Yeah. I've done all the manual thing. This is now automating it. I don't use Department Code and assumed it was for convenience only. Its just that when I do the above code, the user cannot see the record unless I go and add Department Code (I don't care about Department Code - I could just put 123 there all the time for all I care). Adding Department Code for some reason allows the user to see the record. Removing Department Code then stops them from seeing it again.

Posted by Admin on 30-Jan-2012 20:03

OK. the plot thickens. I just ran a test with deptCode being set via the api as per above and it still does the same. This time, I clicked Edit on the relevant Department, then Save (without changing any fields) and the record appeared.

Posted by Admin on 30-Jan-2012 20:31

It would seem like it is something to do with the hierarchy of the department that saving it manually does. Creating a new department via "Create New Record" or "Object Script" triggers does not seem to apply hierarchy correctly. It visually looks right in the Department table (ie parent is set correctly) but it does NOT appear in the Department tree at the top of the Department window. Edit/Save without changing anything makes it appear correctly in the tree.

Posted by Admin on 30-Jan-2012 21:12

OK, got it. I'll check if API behaves differently with respect to LDF then regular UI.

Posted by Admin on 30-Jan-2012 21:41

Thanks Pavel. Any info would be good as I discovered this very late in the process of about to release some software :(. At the moment I'm trying to work up a work-around.



Fil

Posted by Admin on 30-Jan-2012 22:06

I'll post updates tonight on rollbase.com, hopefully that will resolve the issue. Are you using Private Cloud?

Posted by Admin on 30-Jan-2012 23:43

Awesome. If you could let me know when that is done that'd be great. The test/dev is on rollbase.com, with the live release to Private Cloud (for which we need the licence file)

This thread is closed