How to create "create or update entity" action on our own?

How to create "create or update entity" action on our own?

  

I have given "yes" to expose to read only for an entity in the core module for security purpose. 

As a result, I can have "Get entity" action only in the child module. I want to create "Create or Update Entity" action on my ownin it. How to do that?

Hi Ananth,

You don't. What you typically should do, is expose an Entity read-only, and provide, in the same core module the Entity lives, an Action that probably does some sanity checks (but no business rule checks! that should be done in a business logic module) like whether mandatory fields are supplied, and calls the CreateOrUpdate Action from the Entity (and returns the Id).

Solution

Hi Ananth

In your core module you need to create wrapper i.e. server action which takes input of record type and returns id. Make that action public and refer that action in another module.

Now you can call that action for create or update operation and just pass source properly.


Thanks and Regards,

Suraj Borade

Solution

@Kilian sir,

I think we published answer simultaneously. :)

Good thing we both wrote basically the same stuff :).

Woww... @Kilian and  @Suraj.. Thanks a lot guys.. It worked :))))))))))))))))))))))

Good to know :). It's more of a standard pattern of how to do things rather than a solution for a specific problem. It should be documented somewhere...