Lock "classification" property in a document

オフライン
Hi, I have "Document" ItemType with a class structure. When I create a Document through the form, I want that it is possibile to choose the classification property only before first saving. If the user saves the Document, it should be not possible to change classification. How can I get this? Thanks Pierluigi
  • Hi Pierluigi, Yes this is possible. What you would do is typically check if the value before and after the update event are different. To do so, you need to pass the classification value to something that can be read after the process : This is requestState ! you could save a requeststate onBeforeUpdate
    RequestState.Add("classification", this.getProperty("classification");
    and read it on afterUpdate :
    string savedClassification= (string)RequestState[“classification”];
    Make sure you delete this value then
    RequestState.Remove("classification");
    RequestState.Clear();
    If this is different, just send back an Error, it will cancel the update process.
  • Hi Yoann, thanks for you reply. I followed your procedure, but I have some problem. I created two methods related to Server Event of Document Itemtype. But when I save (update) the Document Form, I can't get any error message and the form is updated. It seems that two strings  (savedClassification and curClassification) are the identical and both updated to the current classification. What is wrong? I pasted two methods: OnBeforeUpdate:
    RequestState.Add("classification", this.getProperty("classification")); return this;
      OnAfterUpdate:
    string savedClassification = (string)RequestState["classification"]; string curClassification = this.getProperty("classification"); if (savedClassification != curClassification) { return this.getInnovator().newError("Classification is changed!"); } RequestState.Remove("classification"); RequestState.Clear(); return this;
    Thanks Pierluigi