Get record Id in SaveRecordRequest handler


Suppose I have a detail page which responsible for creating object A record.

I would like to get the record id immediately after it is created and pass it to a business process to do something else.

My current method of doing it is trigger crt.SaveRecordRequest immediately after when the user clicked the save button, and try to get the record Id of the detail object, but I have no idea how should it be done in custom module.


Any idea?

Thanks for the help.

File attachments
Like 1




You must first allow the base save request handler to fire, then you can retrieve the record Id. 

	request: "crt.SaveRecordRequest",
	handler: async (request, next) => {
		// allow base handler to execute
		const saveResult = await next.handle(request);
		// retrieve record Id
		const id = await request.$context.Id;
		// return handler result
		return saveResult;


Hi Ryan, thanks for the help and suggestion.

I had tried on the suggested way, but I was unable to obtain the Id as console shows undefined despite after the record has been successfully saved.




Console result:



Show all comments