Service backed record related action fails sometimes (especially when its started from site. )

We have service backed record , which fetches data from executestoredprocedure function. This is behaving very weird and various kinds of behaviour 

1) When related action is clicked, it leads to either one of the three behaviours , a)it shows the task properly b) activity chaining break but task is available for user c) throws red screen error with below mentioned message but task is still available in tasklist

An Error Has Occurred An error occurred while applying the context for the Deployment related action [identifier=18]. Details: An error occurred while retrieving the data for “Deployment”.

2) For all the case above mentioned the task is generated and working properly. 

3) Identifier mentioned above is not the identifier of selected record, coding doesn't have any issues. since I have passed hardcoded still getting wrong identifier .(and it increments in weird way)

4) This related action works as expected from tempo record, it was consistent. However in site it works sometimes and it doesn't. 

 

Can someone please let me know if anyone has faced any kind of issues. 

  Discussion posts and replies are publicly visible