user_address property

FieldUserAddress.user_address property

Gets or sets the current user’s postal address.

@property
def user_address(self) -> str:
    ...

@user_address.setter
def user_address(self, value: str):
    ...

Examples

Shows how to use the USERADDRESS field.

doc = aw.Document()
# Create a UserInformation object and set it as the source of user information for any fields that we create.
user_information = aw.fields.UserInformation()
user_information.address = '123 Main Street'
doc.field_options.current_user = user_information
# Create a USERADDRESS field to display the current user's address,
# taken from the UserInformation object we created above.
builder = aw.DocumentBuilder(doc=doc)
field_user_address = builder.insert_field(field_type=aw.fields.FieldType.FIELD_USER_ADDRESS, update_field=True).as_field_user_address()
self.assertEqual(' USERADDRESS ', field_user_address.get_field_code())
self.assertEqual('123 Main Street', field_user_address.result)
# We can set this property to get our field to override the value currently stored in the UserInformation object.
field_user_address.user_address = '456 North Road'
field_user_address.update()
self.assertEqual(' USERADDRESS  "456 North Road"', field_user_address.get_field_code())
self.assertEqual('456 North Road', field_user_address.result)
# This does not affect the value in the UserInformation object.
self.assertEqual('123 Main Street', doc.field_options.current_user.address)
doc.update_fields()
doc.save(file_name=ARTIFACTS_DIR + 'Field.USERADDRESS.docx')

See Also