Eventhandler:
Problem:
Recently, when developing eventhandler, we found that if the itemadded method updates the list items, the item is executed. update () will trigger the eventhandler event itemupdated. Our intention is to edit the event.
Trigger the eventhandler itemupdated.
Public Override VoidItemadded (SpitemeventpropertiesProperties)
{...
Properties. listitem. Update ();
}
Public Override VoidItemupdated (SpitemeventpropertiesProperties)
{
// Update code here
}
Solution:
Add the disableeventfiring () method to prevent other events from being called.
Public Override VoidItemadded (SpitemeventpropertiesProperties)
{
Disableeventfiring (); // prevents events from being raised.
...
Properties. listitem. Update ();
}
Or do not use proPerties. listitem. Update ();
Change to properties. listitem. systemupdate ();
Public Override VoidItemadded (SpitemeventpropertiesProperties)
{
...
Properties. listitem. systemupdate ();
}
Splistitem. systemupdate updates the database with changes made to the list item without processing changes in the modified time or modified by fields.
User, item data type
We useCodeWhen accessing the user or the item data type, you need to process some strings before using the data,
Because of the two types, the string format obtained by using the code item ["author"]. tostring () is ID; # displayname
///Get the ID by string format as: ID; # displayname
///Query item, user string
Public Static IntGETID (StringVal)
{
Return Int32. Parse (Val. substring (0, Val. indexof (';')));
}
///Get the displayname by string format as: ID; # displayname
///Query item, user string
Public Static StringGetdisplayname (StringVal)
{
ReturnVal. substring (Val. indexof ('#') + 1 );
}
Workflow:
Workflow. xml configuration
A job usually has an initialization form and a task form, but in some cases we do not need to initialize the form, that is, the workflow only has a task form. In this case, workflow. the xml configuration file needs to be modified accordingly.
There is an initialization formThese nodes are required:
<Workflow
Instantiationurl = "_ layouts/iniwrkflip. aspx"
Modificationurl = "_ layouts/modwrkflip. aspx">
<Metadata>
<Instantiation_formurn/>
<Task0_formurn/>
<Statuspageurl> _ layouts/wrkstat. aspx </statuspageurl>
</Metadata>
</Workflow>
Only a workflow with a task form (if this is not the case, an error occurs in the workflow ):
<Workflow
Modificationurl = "_ layouts/modwrkflip. aspx">
<Metadata>
<Task0_formurn/>
<Statuspageurl> _ layouts/wrkstat. aspx </statuspageurl>
</Metadata>
</Workflow>