cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with new document plugin

popeye
Champ in-the-making
Champ in-the-making
I have written a new document plugin that should just change the value of a certain property when executing the plugin. This works fine but the value has not been saved to the backend. It is strange because after executing the plugin the value has been changed - it is just not persistet…
Here is my code snippet:
  public void onClickEvent(OwObject oObject_p, OwObject oParent_p, OwClientRefreshContext refreshCtx_p) throws Exception
    {       
        OwProperty assignee = oObject_p.getProperty("D:smileysurprised:wd:hrdocument.owd:documentAssignee");
        OwBaseUserInfo userInfo = getContext().getCurrentUser();
        if (null != assignee && null != userInfo) {
           assignee.setValue(userInfo.getUserDisplayName());
        }
       
        if (null != refreshCtx_p) {
           refreshCtx_p.onClientRefreshContextUpdate(OwUpdateCodes.UPDATE_OBJECT_PROPERTY, null);
           }
    }
1 REPLY 1

chfi
Champ in-the-making
Champ in-the-making
The value gets persisted by adding the property to a property collection => this will be saved to the document object. Here is the code that should work:
    public void onClickEvent(OwObject oObject_p, OwObject oParent_p, OwClientRefreshContext refreshCtx_p) throws Exception
    {       
        OwProperty assignee = oObject_p.getProperty("D:smileysurprised:wd:hrdocument.owd:documentAssignee");
        OwBaseUserInfo userInfo = getContext().getCurrentUser();
        if (null != assignee && null != userInfo) {
           assignee.setValue(userInfo.getUserDisplayName());
           OwPropertyCollection props = new OwStandardPropertyCollection();
           props.put("D:smileysurprised:wd:hrdocument.owd:documentAssignee", assignee);
           oObject_p.setProperties(props);
        }