Pregunta

Estaba usando un flujo de trabajo para cambiar los nombres de archivos a algún texto y la ID de SP, pero esto ha causado problemas porque los flujos de trabajo a menudo pueden tardar varios minutos en completarse.Me gustaría hacer esto durante el artículo, pero tengo un 99.999% seguro de que esto no es posible, ya que la identificación probablemente no está asignada hasta que se cargue el documento.Creo que podría usar un artículo, pero no sé cuánto tiempo podría tomar para comenzar.¿Son de estas ideas razonables?

¿Fue útil?

Solución

This sort of task is more suited to an event receiver. The itemAdded approach will certainly give you access to the ID. An event receiver does not have the typical delay you see with Workflows, it fires right away.

One issue you can experience with ItemAdded events is that they run asynchronously. What this means is that the control is returned to the UI while the Event Receiver is kicked off. This can cause situation where the event receiver is not quite done processing before the display returns to the user, and they won't see the updated values until they refresh the page.

The solution to this is to set the mode for the ItemAdded event receiver to Synchronous in the Elements.xml file for the event receiver using :

  <Synchronization>Synchronous</Synchronization>

In context:

<Receiver>
  <Name>Test_ListEventReceiversItemAdded</Name>
  <Type>ItemAdded</Type>
  <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
  <Class>TestEventReceivers.Test_ListEventReceivers.Test_ListEventReceivers</Class>
  <Synchronization>Synchronous</Synchronization>
  <SequenceNumber>10000</SequenceNumber>
</Receiver>

With the Synchronous mode, the display won't return to the user until the processing is complete.

Otros consejos

You can do that in ItemAdded and make it synchronous so it will fire and execute in the same thread after ItemAdding is finished.

You can make an after event syncronous when you define it in your solution, or you can do it with code or PowerShell script.

Licenciado bajo: CC-BY-SA con atribución
scroll top