Updated By field?
Hi, Im creating some basic workflow to send a notification when someone update a record (a task), but I can not see how to get who made the last update... just who create the record.
How can I access to who made the last change on some record?
Right now my code block are making this query:
query SearchUserByID($userId: UUID!) {
workspaceMembers(filter: { id: { eq: $userId } }, first: 1) {
edges {
node {
id
userEmail
name {
firstName
lastName
}
}
}
}
}
Thanks.
34 Replies
It's not possible since there's no updatedBy field, only updatedAt
The basic way would be to create a relation type field to workspace member records (belongs to one) and create a workflow that basically every time any record of this object is updated, it'll update the previously created field with workspace member who did that
Thanks. I will try something like that.
The only problem is that workflow will be limited to only one object so if you want to extend this to more objects, you have to create the same workflow for more of them
I see the option to export a workflow... where can I import one? (so I can duplicate a workflow)
I don't think there's one, @thomast?
Technically it's possible to do it even easier with apps as now Twenty slowly has more extensions to do it, so you can also create an app which do it automatically, problem is it'll be also limited to one type of object like workflows and can result in accidental DDoS due to recursion
EDIT: Nvm, for now it's not possible, recursion will happen
@ap0st0L I can prepare a plugin/app which will automatically update the field in all objects once type of updated object is exposed to apps, although I can't say when exactly it'll be available as distribution of apps is in very early stage
EDIT: another problem appears that when trying to create a relation field via API as it's currently unsupported, so there's nothing I can do until core team adds a possibility
EDIT: another problem appears that when trying to create a relation field via API as it's currently unsupported, so there's nothing I can do until core team adds a possibilityYou should be able to create any fied you want through the API, maybe there's an assymetry between the rest and graphql one relation field creation Could you please share any errors while creating a relation field through the REST API ?

That seems to be a rest issue
Could you please double check that you can create this using gql resolver ?
Don't think so
I reported the problem regarding GraphQL that it doesn't expose standard object, only few custom ones
I'll try either way
So the issue is not creating a relation field but rather creating a relation field on a standard object ?
The issue is creating a relation field without actually being able to specify the relation between which objects as relation object isn't exposed in REST API
What I'm trying to mean is that creating a relation field does not seem to be broken atm
Ok I see
And when I try to create one without using relation object in request data, this is returned

And how do I create something via GraphQL? 😅
Will share a video on how to do so in ~5 mins
From graphql api playground
- Add a new mutation
- Find the mutation you want click on it and select what you want to send
- define either variables or manually write static input in the mutation


I think the REST api validator does not map the field metadata type correctly
🤔
I'll check REST validator later, now I'm trying to figure out relationCreationPayload
If you want you can get an example by creating one in the UI
Atm quite busy srry
And look it up in Network tab 👍
No problem, thanks for your help
Nw ! let me know
I don't really have an idea how to bypass a JSON limitation as
- createOneField offered by GraphiQL accepts only string but giving stringified JSON returns an error
- createOneMetadataFieldItem found in Network tab accepts JSON but when everything is transferred to GraphiQL, it shows that relationCreationPayload should be JSON (but I guess it interprets as object?), when sent like this or stringified, it returns an METADATA_VALIDATION_FAILED error
Okay, found my way, nasty and not really proud but working
In short, literally copy pasting the payload from Network made it work so that's something but finding a way through it can be quite annoying
Hey, I would recommend settings variable for formatting the relationCreationPayload
Using such extension can help https://chromewebstore.google.com/detail/graphql-network-inspector/ndlbedplllcgconngcnfmkadhokfaaln
GraphQL Network Inspector - Chrome Web Store
Simple and clean network inspector for GraphQL
To copy vars and query as highly replayable
I'll try it
Okay, that worked, thanks for help!
Congrats !
@Prastoin there's another problem, updating relation field via API results in error https://github.com/twentyhq/twenty/pull/15513#issuecomment-3481672609
GitHub
[HACKTOBERFEST] Updated by extension by BOHEUS · Pull Request #155...
This PR adds Updated by extension which creates "Updated by" relation type field to workspaceMembers records if it doesn't exist and updates it whenever user changes somet...
What are you trying to update on the relation field ?
Relation field edition is forbidden by definition
Update the workspace member id to show who's responsible for last changes
Wait, really? Why?
Updates on a UUID field should not be an issue
But you can edit anything on a relation field for the moment ( even the label and desc 😛 in coming soon ) because it break to many indexes under the hood in db
In the API?
What in the api ?
This
Nvm, understood, was thinking about something else
I'll send my GraphQL and REST API payloads once I'm back to show and check if I'm doing something wrong
REST API payload to PATCH /post/{objectName}/{id}
GraphQL API payload (taken from Network tab and modified to be generic)