Moss development tips

Source: Internet
Author: User

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>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.