MattParr/python-atws

UserDefinedField Initialize a value

Closed this issue · 5 comments

I have a problem to initialize the value of an userDefinedField, the fourth,

  UserDefinedFields =
     (ArrayOfUserDefinedField){
        UserDefinedField[] =
           (UserDefinedField){
              Name = "Date de Création Sophia"
              Value = "10/20/2016"
           },
           (UserDefinedField){
              Name = "Kaseya Customer ID"
           },
           (UserDefinedField){
              Name = "Lead Source"
           },
           (UserDefinedField){
              Name = "Number of Employees"
           },
           (UserDefinedField){
              Name = "Services Sophia"
              Value = "Lien d'accès- Téléphonie mobile (Orange V1- Orange)"
           },
     }

Trying to initialize the value :
account.UserDefinedFields[0][0][4].Value = "services Sophia..."

The error :
IndexError: list index out of range

my_udf_value = ticket.get_udf('My Udf Name')

I would initialize rather than get

I have an error with get :

Traceback (most recent call last):
File "create_account_simple_example.py", line 30, in
my_udf_value = account.get_udf('Services Sophia')
File "/usr/local/lib/python2.7/dist-packages/atws/monkeypatch/userdefinedfields.py", line 19, in mp_get_udf_value
return helpers.get_udf_value(entity._wrapper, entity, name, default)
File "/usr/local/lib/python2.7/dist-packages/atws/helpers.py", line 42, in get_udf_value
udf = get_udf(wrapper,entity,name,default)
File "/usr/local/lib/python2.7/dist-packages/atws/helpers.py", line 76, in get_udf
raise AttributeError('no udf named {}'.format(name))
AttributeError: no udf named Services Sophia

account.set_udf('<udf_name>', '<udf_value>')

account.set_udf('<udf_name>', '<udf_value>')
it works
thanks