Forum Discussion

AngelaIp's avatar
AngelaIp
Ideator I
7 years ago
Solved

How to use request states for multiple items at the same time?

Hi Community, maybe somebody has faced a similar task before and can give me some hints. I have an relationship onAfterDelete server Method that is triggered when an relationship item is deleted....
  • cogres's avatar
    7 years ago

    Hi Angela, 

    my previous post was marked as spam for some reason, so I will try again:

    You can have any object as your value for a key in RequestState. So in your onBeforeDelete method you could include something like this:

    if (RequestState.Contains("prevRelID")) {

    List<string> relIdList = (List<string>)RequestState["prevRelID"];

    relIdList.Add(this.getProperty("related_id", ""));

    } else {

    RequestState.Add("prevRelID", new List<string> { this.getProperty("related_id", "") });

    }

    So on your onAfterDelete method, you can now access this list of related IDs with something like

    List<string> relIdList = (List<string>)RequestState["prevRelID"];

     

    Hope this helps some.

    Cheers,

    C