Model SDK - Action Activity - change object example /sample code

Hi, It would be very helpful if someone could provide sample code  of how to add a 'Change Object' activity to an existing microflow and demonstrate chaning a few attributes as an example.  As shown in the screenshot, I am trying to copy one entity into another, problem is - there are hundreds of attributes. Look forward to doing this by code in Model SDK.  
1 answers

This is the code I have used when I played around with the SDK to create activities. Note: this code assumes many things about the complete structure of the microflow, such as the existence of an Address object and the existence of a Customer entity with attributes Street and City etc.


function addActivities(microflowToAdd: data.Microflow, newMicroflow: microflows.Microflow): microflows.MicroflowObject[] {
    let objects: microflows.MicroflowObject[] = [];
    let objCol = newMicroflow.objectCollection;
    let start = createStartEvent(newMicroflow);
    microflowToAdd.activities.forEach(activity => {
        let action = microflows.ActionActivity.createIn(objCol);
        const coordinates = getCoordinatesForMicroflow(microflowToAdd, activity, 1);
        action.relativeMiddlePoint = {x: coordinates.width, y:coordinates.height}; 
        action.size.height = 60;
        action.size.width = 120;
        switch (activity.type) {
            case data.ActivityType.ChangeObject:
                let changeObject = microflows.ChangeObjectAction.createIn(action);
                changeObject.commit = microflows.CommitEnum.No;
                changeObject.refreshInClient = true;
                changeObject.changeVariableName = 'Customer';
                let changeStreet = microflows.MemberChange.createIn(changeObject);
                changeStreet.attribute = newMicroflow.containerAsFolderBase.model.findEntityByQualifiedName('CustomerManagement.Customer').attributes.filter(a => == 'Street')[0];
                changeStreet.value = '$Address/Street';
                let changeCity = microflows.MemberChange.createIn(changeObject);
                changeCity.attribute = newMicroflow.containerAsFolderBase.model.findEntityByQualifiedName('CustomerManagement.Customer').attributes.filter(a => == 'City')[0];
                changeCity.value = '$Address/City';
    let end = createEndEvent(microflowToAdd, newMicroflow);
    return objects;


I would imagine that in your code, you would loop over the attributes of one of the entities and add a Microflows.MemberChange for each attribute you encounter. You would set the value based on an existing object/attribute combination, like I have done.