开发者

how to avoid a particular record to be opened by anybody else in MS CRM

In my application i want to 开发者_StackOverflow中文版prevent any other user from opening the record of particular client while somebody has already opened it. And show him somekind of error or alert.

How should i do that?? I appreciate any answers or suggestions.

Thanks,


There is no simple way to do this, but you can do what GCATNM mentioned before me. I would add one thing, though.

If this is an on-premise installation, you can set up an asmx service that accepts an entityid and a username. This will update the lockedOn date of the attribute with the current date. Then, have a script that runs on the entity record that calls this asmx every minute to update the lockedOn date. This tells the system that you are still actively using this record.

Then, in your code that checks to see if anyone is locking the entity, you ignore any locks that have a lockedOn date more than 5 minutes ago.


You could add a lookup to systemuser ("Currently opened by") to the entity, and when the form is opened, check whether it has a value. If so, display a message and close the form or forward to the readonly form. If not, set the lookup to the current user via a webservice call (so that it's actually in the database that same moment), so everyone else gets the notification when opening the form. When saving or otherwise closing the form (onbeforeunload event), do another webservice call (or, when saving, simply set the empty lookup's ForceSubmit property to true) to clear the lookup.

Note that this will not catch certain things like a crashing client (which would leave the record "locked"), so you'd need some kind of failsafe, like a workflow that clears the lookup after it has been set and the record has not been modified again for a certain time.

Also, any other logic that might modify the record (like plugins, imports, any custom development) would have to be done in a way that avoids collisions with this "locking" functionality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜