Update Relationship Fields
When you call the updateRelationshipField method to update a Relationship field, you must use the same required parameters as for updateField. Additionally, you can update attributes for related relationships, such as type, name, and targets. You specify the relationship to be updated by using the Relationship object. Only the non-null attributes you set for the Relationship object that are passed as parameters are updated, and the rest are left unmodified.
|
If you modify the number of target objects for a relationship, changes to the data type of the related field can be generated (for example, from Relationship to Dynamic Relationship). This is the only supported data type change, and when it occurs, field options are recreated accordingly.
|
updateRelationshipField() Method Definition
public static IMaxObject updateRelationshipField(String relatedObjectFullIdentifier, String fieldFullIdentifier, Relationship relationship, Map<String,Object> values)
Example
To update the test_relationship_field in the Showcase object to change its target to only the User object and modify its short description and update-safe attributes:
import com.servicemax.core.utils.Definitions
import com.servicemax.core.definitions.Relationship
def relationship = Relationship.fromMap([targets: ['io_user']])
Definitions.updateRelationshipField('io_showcase', 'io_test_relationship_field', relationship,
[io_application: 'Max Designer', io_short_description: 'Field used by Showcase', io_update_safe: true])
For more information: