DataMutations for Relationships in custom DHIS2 app

I currently creating a DHIS2 embedded application. I have a trackedentity which i want to link to specific events.

Ideally I would want to assign additional information to this this relationship. A sample that I have that is working for the relationships is this:

const mutationRelationships = {
    resource: 'relationships',
    type: 'create',
    data: ({ trackedEntityInstance, courseId, score, type }) => ({
        relationshipType: type,
        from: {
            trackedEntityInstance: {
                trackedEntityInstance: courseId,
            },
        },
        to: {
            trackedEntityInstance: {
                trackedEntityInstance: trackedEntityInstance,
            },
        },    
    }),
};

I have unsuccesfully tried to add attributes to this relationship creation - the relationship is created - but the attributes are not pushed through. Any advise on that?

Hi @matthew_deas

You’d need to follow the DHIS2 API’s schemas as noted in the developer guide.

The property names of data must correspond to the property names in the DHIS2 API. (source)

Here’s an example on how to find the list of properties to include: DHIS 2 Demo - Sierra Leone

I hope this helps…