Attributes won't populate using the Granta SDK/STK 2.0?
James Derrick
Administrator, Employee Posts: 283
admin
I am creating a new record using the granta stk 2.0, but when I look at it in viewer none of the attributes are populated. Where am I going wrong?
my_record = mi_table.create_record('my record') my_record.attributes['record ID'] = '000IK' my_record = session.update([my_record])[0]
Tagged:
0
Answers
-
In the GRANTA MI:Scripting Toolkit v2.0 attributes need to be set on the record, before they are updated. All that is needed to get your code snippet to work is to add the following line:
my_record.set_attributes([my_record.attributes['record ID']])
after the record is created but before the
Session.update()
method is called. Additionally you can set attribute values to be cleared/deleted using theRecord.clear_attributes()
method. In 2.2 any empty attributes that are added usingset_attributes()
will be cleared/deleted also.Full code:
my_record = mi_table.create_record('my record') my_record.attributes['record ID'] = '000IK' my_record.set_attributes([my_record.attributes['record ID']]) my_record = session.update([my_record])[0]
2