cancel
Showing results for 
Search instead for 
Did you mean: 

Import/export users/groups

srowsell
Champ in-the-making
Champ in-the-making
I'm trying to be able to export my datalist to .csv.  I have a specific solution already built as a web script (though I'm finding a more general solution troublesome), but for now specific will do.  The problem is that two of the properties of the datalist are a group and user (respectively) as can be seen from the excerpt from the model at the end of this post.  The "recipientUser" and "recipientGroup" properties work just fine in the datalist, but don't know how to export or import values for them which can be stored in a .csv file.

Any thoughts?


<types>
   <!–   Data list defintions For this model go here –>
   <type name="reportdl:reportRecipientsDatalist">
      <title>Reports Data List</title>
      <description>Report Recipients Data List</description>
      <parent>dl:dataListItem</parent>
      <properties>
         <property name="reportdl:department">
            <title>Department</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
            <constraints>
               <constraint ref="reportdl:departments" />
            </constraints>
         </property>
         <property name="reportdl:reportName">
            <title>Report Name</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="reportdl:uniqueIdentifier">
            <title>Report Unique Identifier</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="reportdl:frequency">
            <title>Report Frequency</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
            <constraints>
               <constraint ref="reportdl:frequencies" />
            </constraints>
         </property>
         <property name="reportdl:suffix">
            <title>Suffix</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
      </properties>
      <associations>
         <association name="reportdl:recipientGroup">
            <title>Recipient Group</title>
            <source>
               <mandatory>false</mandatory>
               <many>true</many>
            </source>
            <target>
               <class>cm:authorityContainer</class>
               <mandatory>false</mandatory>
               <many>true</many>
            </target>
         </association>
         <association name="reportdl:recipientUser">
            <title>Recipient User</title>
            <source>
               <mandatory>false</mandatory>
               <many>true</many>
            </source>
            <target>
               <class>cm:person</class>
               <mandatory>false</mandatory>
               <many>true</many>
            </target>
         </association>
      </associations>
   </type>
</types>

1 REPLY 1

srowsell
Champ in-the-making
Champ in-the-making
Okay, I have the specific solution for exporting the data, which end up looking like this:

CBC,NSFs,NSFs,Daily,b16,,GROUP_ALFRESCO_ADMINISTRATORS
Richmond Hill,Large Amounts,LargeAmounts,Daily,b9,,GROUP_ALFRESCO_ADMINISTRATORS
Unknown,403_UnextendedCredit.select,403_UnextendedCredit,Unknown,Nil,,
Unknown,191_LOANS_-_TORONTO.select,191_LOANS_,Unknown,Nil,,
Deposits,Activity,Activity,Daily,y46,,GROUP_ALFRESCO_ADMINISTRATORS


The last two fields in each record refer to the two associations mentioned in the datalist model, and they represent arrays of person or group objects (respectively), and will be separated by a ^ if there is more than one value.  My problem, though, is how to turn the person's userName or the group's name (or names) into such an array of objects and then write the datalist record to the datalist.  Let's say that I had the code like the following:

var entry = depoList.createNode(null,reportdl:reportRecipientsDatalist);
   entry.properties["reportdl:department"]="CBC";
   entry.properties["reportdl:reportName"]="NSFs";
   entry.properties["reportdl:uniqueIdentifier"]="NSFs";
   entry.properties["reportdl:frequency"]="Daily";
   entry.properties["reportdl:suffix"]="b16";
   entry.properties["reportdl:recipientUser"]=userArray;
   entry.properties["reportdl:recipientGroup"]=groupArray;

   entry.save();


In this case, userArray and groupArray are arrays of objects.  In particular,

groupArray[0]=people.getGroup("GROUP_ALFRESCO_ADMINISTRATORS");


I do this, and I don't get the group added to the datalist record.  I've also tried the line like:

entry.assocs["reportdl:recipientGroup"]=groupArray;


But this also doesn't work.  The recipientUser and recipientGroup are clearly associations, which appears to be the problem, but I don't know how to add an association to the entry object which will get written to the datalist, but the only way to have users and groups as part of the datalist is to have them as associations.

An alternative just occurred to me, but I really don't like it.  I could change the datalist to use just the flat username or group name, but this would limit me to one of each at a maximum unless I do something like create an array using a parsing character.

I'm very much open to suggestions.

Steve
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.