locked
SPListItem[FieldName] is null if the workflow start when a new item is created RRS feed

  • Question

  • Dear all,

    As title, I get null for SPListItem[FieldName] if the workflow start when a new item is created. However, it is not null when I start the workflow manually.

    How can I get the value of SPListItem[FieldName] even if the workflow start automatically?

    Thanks,

    Ray

    Tuesday, January 31, 2012 8:04 AM

Answers

All replies

  • Dear all,

    I find that it only happens in Windows 7, from the following link

    http://stackoverflow.com/questions/2044200/why-does-my-sharepoint-workflow-fail-when-the-client-is-running-vista-or-windows

     

    From the link, I know that Windows 7 saves InfoPath forms through WebDAV. So SharePoint catches the "ItemAdded" event before the file is actually uploaded. It suggests to use delayactivity in order to wait until the file is uploaded. Is there other method to do that? like while loop to check if the item exist or not?

    Moreover, for the delayactivity, after calling the delay, it does not wake up again.

    Please help.

    Thanks,

    Ray

    Wednesday, February 1, 2012 8:50 AM
  • Hi RAYSW,

     

    You can use attribute AfterProperties, You add the item by workflow, so I think you should use the code like the following like this.

     

      public override void ItemAdding(SPItemEventProperties properties)

            {

                base.ItemUpdated(properties);

             

                string name=properties.AfterProperties["Title"].ToString();  

            }

     

    Thanks,

    Jack  

     

    Thursday, February 2, 2012 9:09 AM
    Moderator
  • Hi Jack,

    Thanks for your reply.

    Sorry that I am not familiar with workflow. 

    I am now using sequential workflow with infopath as input form. The workflow will start automatically after a new infopath is created.

    Then can I still use ItemAdding in my code? It compiles with error after I add the method.

    Thanks,

    Ray

     

    Friday, February 3, 2012 2:55 AM
  • Hi Ray,

     

     

    Can you give me the details error or can you put your code in forum? 

     

     

    Thanks,

    Jack


    Friday, February 3, 2012 3:03 AM
    Moderator
  • Dear Jack,
    My workflow is as shown in the picture above. I do not use ItemAdding within my workflow. When I add it, it just prompts the error that "no suitable method found to override"
    If I use "onWorkflowActivated", can I still get the problem solved by using "afterproperties"?
    Thanks a lot,
    Ray
    Friday, February 3, 2012 4:01 AM
  • Hi Ray,

    I' m sorry for ItemAdding , the attribute of the afterproperties is in event handler not for workflow. When you start the workflow manually, the SPListItem[FieldName] is not null, but when you start automatically, it is null. So, may be have a delay. so, please check the following link.

     http://mkdot.net/blogs/zzl/archive/2009/01/29/sharepoint-workflows-and-delayactivity-problem.aspx

     http://sladescross.wordpress.com/2010/01/06/sharepoint-workflow-delay-activity-issues/

     

    Thanks,

    Jack

    • Marked as answer by RAYSW Monday, February 6, 2012 6:44 AM
    Friday, February 3, 2012 4:43 AM
    Moderator
  • Hi Jack,

    Thanks.

    I have already tried to use delayactivity but it does not work. I just simply add the delayactivity in the beginning of the workflow. Is it not correct? should it be inside listenactivity?

    I have already checked the link you provided before that I have followed all steps (e.g. already sp2, change the job-workflow to every 1 minutes between 0 and 59) except that I do not know what will be happened in the field "DeliveryDate" of the database "WSS_Content.dbo.ScheduledWorkItems".

    Should it be updated when delayactivity is used, however, I find that it is not updated. It only contains one record and the date is when I install the sharepoint. Is it normal? If it is not normal, what should it be when using delayactivity?

    Please help. I have been confused by this problem for several days.

    Thanks,

    Ray

    Friday, February 3, 2012 6:40 AM