List Info

Thread: Re: custom fields and synchronizing ogo




Re: custom fields and synchronizing ogo
country flaguser name
Germany
2008-03-27 08:08:29
xmlrpcopengroupware.org wrote: 
> Hi Adam,
> 
> xmlrpcopengroupware.org wrote: 
> > > I assume the two lines below the import line
have to be on a single 
> line?
> > 
> > yep.
> > 
> > > Then I see a lot of, maybe only in my eyes,
magic numbers, e.g.:
> > > permissions = [ { 'operations' : 'rw',
> > >                   'targetObjectId' : 970990
},
> > >                 { 'operations' : 'rw',
> > >                   'targetObjectId' : 11530 }
] 
> > > are 11530 and 970990 object ID values of
accounts or teams in ogo?
> > 
> > Teams;  these permissions "rw" for teams
970990 & 11530 are set on all
> > imported values.  Obviously that would be
different or unnecessary
> > depending on the site.  They can be objectIds of
accounts or teams.
> > 
> > > then, a little bit later when creating the
Enterprise:
> > > ...
> > >                  '_ACCESS' : permissions,
> > >                  '_COMPANYVALUES' : [ {
'attribute' : 'division',
> > >                                        
'value' : 'WYC' },
> > >                                       {
'attribute' : 'salesperson',
> > >                                        
'value' : row[0] },
> > > ...
> > > I assume this will create all companies with
a "division" attribute 
with 
> > > value WYC?
> > 
> > Yep.
> > 
> I took a look at the example scripts on the zogi wiki,
and I am able to 
> create a company, also the extended attributes. I am
having a problem 
> creating adding the contact_id to an enterprise.
> 
> I took a look into the wiki, putObject examples, there
you do sth like 
this:
> 
> ...
> person = {}
> person['targetObjectId'] = 10160
> ...
> enterprise['_CONTACTS'] = [ person ]
> ...
> enterprise = server.zogi.putObject(enterprise)
> 
> 
> The script I use, is:
> 
> #!/usr/bin/env python
> # all intranet: 10003
> #                
> 
> import sys, csv, xmlrpclib, time
> server = 
xmlrpclib.Server('http://admin:pwlocalhost/zidestore/so/ogoroot')
> permissions = [ { 'operations' : 'rw',
>                   'targetObjectId' : 10003 } ]
> counter = 0
> reader =
csv.reader(open("/root/bin/company.csv",
"rb"), delimiter='|', 
> quoting=csv.QUOTE_NONE)
> for row in reader:
>     print 'Creating new enterprise'
>     person = {}
>     person['targetObjectId'] = row[11]
>     enterprise = server.zogi.putObject(
>                { 'objectId' : 0,
>                  'entityName' : 'Enterprise',
>                  'name' : row[1],
>                  'url' : row[2],
>                  '_ADDRESSES' : [ { 'name1' : row[1],
>                                     'street' : row[3],
>                                     'city' : row[6],
>                                     'state' : row[5],
>                                     'zip' : row[4],
>                                     'type' : 'ship' }
],
>                  '_ACCESS' : permissions,
>                  '_CONTACTS' : person,
>                  '_COMPANYVALUES' : [ { 'attribute' :
'contact_segments',
>                                         'value' :
row[7] },
>                                       { 'attribute' :
'contact_markets',
>                                         'value' :
row[8] },
>                                       { 'attribute' :
'country',
>                                         'value' :
row[9] },
>                                       { 'attribute' :
'continent',
>                                         'value' :
row[10] },
>                                       { 'attribute' :
'CSDB_Import',
>                                         'value' : 'YES'
},
>                                       { 'attribute' :
'csdb_id',
>                                         'value' :
row[0] }
>                                         ] }
>       )
>     print 'Created Enterprise#%d' %
enterprise['objectId']
> 
After reading about assignments in the Wiki, I changed the
script, so that 
it looks like this:

                 '_ACCESS' : permissions,
                 '_CONTACTS' : [ { 'targetObjectId' :
row[11] } ],
                 '_COMPANYVALUES' : [ { 'attribute' :
'contact_segments',
Now, the exception is gone, and the entry is created, but
the contact_id 
field in the database is still empty.


> 
> The CSV file had the following contents:
>
401|TESTCOMPANY|www.testcompany.de|Testblah|ZIP||asdf|2|1|10
|1|894900
> 

kind regards
Sebastian

-- 
OpenGroupware.org XML-RPC
xmlrpcopengroupware.org
http://mail.opengroupware.org/mailman/listinfo/xmlrpc

Re: custom fields and synchronizing ogo
country flaguser name
United States
2008-03-27 10:05:19
> After reading about assignments in the Wiki, I changed
the script, so that 
> it looks like this:
>                  '_ACCESS' : permissions,
>                  '_CONTACTS' : [ { 'targetObjectId' :
row[11] } ],
>                  '_COMPANYVALUES' : [ { 'attribute' :
'contact_segments',
> Now, the exception is gone, and the entry is created, 

So the enterprise is created and the specified contact
appears linked to
the enterprise?  That is what is supposed to happen.

> but the contact_id field in the database is still
empty.

???  Don't understand.  The contact_id isn't related to
contact<->enterprise assignment.  In fact,  I don't
really have any idea
what the purpose of the contact_id field is. 
Enterprise<->Contact
relationships are records in the company_assignment table.
Enterprise<->Contact is a [potentially] many:many
relationship.

I think a contactId is available in late version of zOGI's
Contact
entity, and it is the value of contact_id.  But, again, 
don't know its
intended purpose.

> > The CSV file had the following contents:
> >
401|TESTCOMPANY|www.testcompany.de|Testblah|ZIP||asdf|2|1|10
|1|894900

-- 
OpenGroupware.org XML-RPC
xmlrpcopengroupware.org
http://mail.opengroupware.org/mailman/listinfo/xmlrpc

Re: custom fields and synchronizing ogo
country flaguser name
Germany
2008-03-27 10:25:17
On 27.03.2008, at 16:05, Adam Tauno Williams wrote:
> In fact,  I don't really have any idea
> what the purpose of the contact_id field is.


Its just an arbitary account which is considered the
'primary customer  
contact' associated with the given contact record. You can
set this in  
the person/company editor.

Greets,
   Helge
-- 
Helge Hess
http://www.helgehess.eu/

-- 
OpenGroupware.org XML-RPC
xmlrpcopengroupware.org
http://mail.opengroupware.org/mailman/listinfo/xmlrpc

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )