Reputation: 113
I have 2 custom entities in CRM 2016, entity a called Equity and entity b called future action. On the Equity form I have a future action subgrid. What I need is when opening a future action form to be able to determine what context it's been opened in. Meaning, have I just opened this future action from an Equity form, or somewhere else (i.e. advanced find). If opened from an equity I need the future action form to be read only. How do I get the context of the previous/parent form when opening a future action?
Upvotes: 1
Views: 932
Reputation: 22836
We did something similar to this. With some unsupported customization, we can achieve.
Attach an event handler to Subgrid Double click & open the Entity form with our custom parameters
This way, on form load you can verify if your param exists - its from subgrid in equity form & make the form read only. Else leave the loaded form as it is (opened from Adv find).
Upvotes: 0
Reputation: 3935
Here are some thoughts on this scenario:
While I agree with Alex that what you're asking "can't be done", perhaps something can be done.
Figuring out if you opened a Create form from another entity is pretty straightforward as long as there's a lookup to the parent entity on the form. If that lookup exists, there should be an automatic mapping that populates it. If that lookup is empty on the Create form, you know a user launched the create form elsewhere.
In situations where I'm relying on mappings to transmit data to a child record, I use JavaScript to check if the parent lookup is blank. If so, I notify the user that they have to create the record from the appropriate parent type, then close the form.
In this case it sounds like you're looking to restrict existing records, not just new ones being created. If all records that have an Equity parent populated should be read-only, you could theoretically configure workflows and security roles to achieve that. When the Equity lookup gets populated you could reassign the record to another user to make it read only.
For example let's say that: Our regular user has Read privs to all Future Actions and write privs to Future Actions that they own.
We have a designated user "CrmAdmin" that has the System Administrator role.
When a Future Action's Equity lookup gets populated, have a workflow assign that Future Action to the CRMAdmin. This will make it read-only for the regular user.
The workflow could also populate a separate user lookup that does not drive security, which you could call "Responsible Person" or "Business Owner" or whatever.
An unsupported (and not recommended) idea would be to open the form from the various locations that users might open it and check window.location.href to see if there are differences that you can hook into.
Upvotes: 0