Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What tools are you going to use? if it is SharePoint Designer I am afraid you cannot do that because SharePoint Designer is weak when it comes to querying for multiple items in a specified list (Sales, in your case).</p> <p>Nevertheless, if you are going to get your hands dirty with code, it's a definite YES. I assume you have already designed your workflow on the sales list. Register an event handler on "Products" list for the event "Item Updating". Karine has a nice post about registering event handlers <a href="http://karinebosch.wordpress.com/walkthroughs/event-receivers-walkthrough4/" rel="nofollow">here</a>.</p> <p>In the event receiver you have to put something like the following code:</p> <pre><code>//Opening a connection to the site using (SPWeb web=properties.OpenWeb()) { //Getting Sales List SPList SalesList=web.Lists["Sales"]; //Building and executing a CAML query to be executed on the sales list to retrieve sales that are related to the product item currently being updated. Note that you need to replace 'RelatedProduct' with the name of the lookup field in sales list that looks up on items in products list. SPQuery qRelatedSales=new SPQuery(); qRelatedSales.Query=string.Format("&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='RelatedProduct' LookupId='TRUE' /&gt;&lt;Value Type='Lookup'&gt;{0}&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;",properties.ItemId); SPListItemCollection relatedSales=SalesList.GetItems(qRelatedSales); //starting workflow on each related sales item. Note that you have to replace "Your Workflow Name" with the title of your workflow on sales list. SPWorkflowAssociation assoc = SalesList.WorkflowAssociations.GetAssociationByName("Your Workflow Name", CultureInfo.CurrentUICulture); foreach(SPListItem relatedSale in relatedSales) { web.Site.WorkflowManager.StartWorkflow(relatedSale, assoc, string.Empty, SPWorkflowRunOptions.Synchronous); } } </code></pre> <p>After this, deploy the project and test whenever a product item updates, the event receiver should run and eventually, your workflow should be run on all sale items related to the product.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload