How to Update Material Request Status to 'Transferred' After Creating Stock Entry for Purpose 'Demo'

I have added a custom purpose named “Demo” in the Material Request. Using a client script, I have created a button that allows users to create a Stock Entry once the Material Request is submitted. Now, I want the status of the Material Request with the purpose “Demo” to automatically update to “Transferred” after the Stock Entry is created. How can I achieve this?