locked
How to update infopath form field after saved to form library RRS feed

  • Question

  • Hello,

    I have a created a form library and submit an infopath form. After i submit the form i want to update some form fields. I want to place the update button below the form, when a user update any field then she will press update button and that particular field will be updated.

    How can i achieve this. How can i update an InfoPath 2010 form field after it submitted to form library ?????

    Thanks in advance.

    Tuesday, April 17, 2012 7:53 AM

Answers

All replies

  • 

    Not sure I clearly understand your post. InfoPath 2010 form allows the users to submit and update the form as many as they want. ONly thing you need to make sure is that submit file name has to be same for updating. If not, it will create a new form and save instead of updating.

    One tip, create a hidden field to store current time by using now() function. It will generate a unique file name for you. Uncheck "Refresh value when formula is recalculated" option, so the value in the hidden field will be same when user submits/updates the form. Use this hidden field as a submit file name.


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com


    • Edited by Sangha Baek MVP Tuesday, April 17, 2012 9:00 PM
    • Proposed as answer by Jason Li - Canada Wednesday, April 18, 2012 3:52 AM
    • Unproposed as answer by Rauf Ab Thursday, April 19, 2012 11:07 AM
    Tuesday, April 17, 2012 8:59 PM
  • Thanks for the reply,

    My question is very simple that how can i update the form (infopath form). you said if the file name is same then it will simply update. No it does not update. It gives me the following error and does not save the file. Please tell me how can i update an infopath form after it submitted to form library, thanks.

    Below is an error.

    The form cannot be submitted because of an error.

    Click OK to resume filling out the form. You may want to check your form data for errors.
    Hide error details
    The form cannot be submitted to the specified SharePoint document library. The document library already contains a file with the same name. A value in the form may be used to specify the file name. If you know what that value is, modify it and try submitting the form again.
    An entry has been added to the Windows event log of the server.
    Log ID:5567

    • Edited by Rauf Ab Wednesday, April 18, 2012 4:23 AM
    Wednesday, April 18, 2012 4:22 AM
  • You have an option to overwrite existing file. Open your InfoPath form and modify submit data connection. At the end of submit connection wizard, you will find a checkbox.

    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com

    Wednesday, April 18, 2012 5:22 AM
  • Thanks sangha,

    The way you told will allow users to update the form after the workflow completes which i dont want. When workflow completes then no body should update the form. Will this handle thorugh code or i can do through out of the box ??? How can i achieve this???. Thanks.



    • Edited by Rauf Ab Wednesday, April 18, 2012 9:47 AM
    Wednesday, April 18, 2012 9:34 AM
  • Workflow is the new thing that you didn't menthion on your first post. You have to ptovide information as much as possible so we can share the most needed knowledge at the beginning. It can be treated as a new question to people in this forum.

    There is a couple of different ways to do it, but I think the easiest approach would be using another hidden field & Read-Only View.

    1. Let's call this hidden field as "Current Status". At the end of your workflow, you add one more extra step to update the value of "Current Status" field as "Completed".

    2. Create a new Read-Only View which contains all fields.

    3. Add a rule on Form Load event as following.

    [If "Current Status" is equal to "Completed"

    Switch View to Read-Only View that you just created.]

    It will allows the users to open the form in Read-Only mode once the workflow is completed.


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com

    Wednesday, April 18, 2012 2:58 PM
  • Thanks Sangha,

    I exactly need the same thing that you mentioned in your last post. I tell you from start that what i need.

    I have an infopath forms which submitted by user and the parallel workflow starts which assign two tasks. When both tasks completed workflow will also complete. So when a workflow completed i dont want any user to allow to update an existing infopath form.

    I want to put "CurrentStatus" dropdown in infopath form. When a workflow starts, its status will show as "pending", and when the workflow completed its status will show as "Completed". I have created "CurrentStatus" drop down in infopath form . But You told me about creating view i dont know how to create view in infopath form please put light on that.

    Now please let me summerize you that what i exactly need is following.

    1 - How to restrict users to update any of the form when a workflow completed for that particular form.

    2 - How to update the "CurrentStatus" value from workflow by using visual studio when it completes.

    I am really thankful for your kind help. i wasted alot of time in these above two problems, I shall be very thankful if i solve my problems from your help.

    Thanks.

    Thursday, April 19, 2012 5:13 AM
  • How to restrict users to update any of the form when a workflow completed for that particular form?

    1. Clcik "Page Design" tab on the top ribbon menu. Click "New View".

    2. Define a name of the view. I gave "Summary" for this demo.

    3. Click "Properties" to open View Properties dialog

    4. Check "Read-only" box

    5. Make sure to add a rule to switch the view when Current Status value is "Completed"

    How to update the "CurrentStatus" value from workflow by using visual studio when it completes?

    1. If you are able to build a workflow using Visual Studio, then it should be faily easy for you. Just add two lines of code on the last workflow step.

    public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
    ...
    workflowProperties.Item["CurrrentStatus"] = "Completed";
    workflowProperties.Item.Update();

    2. If you want to use CurrentStatus field value in your workflow, then you have to promote InfoPath field (CurrentStatus field) to column in Form Library. When you run InfoPath publish wizard by clicking "Publish" button, it will ask you to select fields for promoting. Select CurrentStatus field.

     Hope it helps


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com


    Thursday, April 19, 2012 6:16 AM
  • Thanks for the reply sangha,

    Iam pasting your code below. I have used this code in the workflow in "CodeActivity" event but it does not update an infopath form field (CurrentStatus). I also promote this field in the form library and modify view to display this column as a form library column, as you can see in image

    Please note this infopath form field "CurrentStatus" is also placed on infopath form, i assumed this infopath field will also programatically update by the following code on infopath form.

    public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
    ...
    workflowProperties.Item["CurrrentStatus"] = "Completed";
    workflowProperties
    .Item.Update();

    • Proposed as answer by VishnuRao Thursday, September 25, 2014 5:28 PM
    Thursday, April 19, 2012 7:39 AM
  • It has a typo. Change CurrrentStatus to CurrentStatus. You might have a different column name. Please check your column name and replace "CurrentStatus" with your column name.

    Column has Display name and Internal name. Diplay name and Internal name can be different. Display name would be fine, but I think it is better to use internal name. Go to Library Settings page --> Scroll down to Column Section --> Click your column name --> Check address bar of your browser. --> I don't have SharePoint installed on my local machine, so i'm not exactly sure but look for &name=[internal name] or &field=[internal name] to find out internal name.


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com




    Thursday, April 19, 2012 8:30 AM
  • Thanks Sangha,

    Iam sorry for the wrong FieldName, It was ok in  my code but mistakenly i typed incorrectly here in the post.

    Please view the code where i write these lines in my code. it gives no error if fieldName is correct otherwise it gives an error. Can you please make me one thing sure that can we exactly update the infopath form field which is placed on infopath form and also update this field as a form library column at the same time by writing these two lines of code ????

    This thing i tried before but never successfull. I near to my soltuion. Please look at this problem again where iam doing mistake.

    Really thanks for your patience :).

    Thursday, April 19, 2012 9:15 AM
  • Hello Sangha,

    Please see the images below that how i use Current Status field in form library and infopath forms. And your below line of code does not update both, infopath form field and a form library "Current Status" field. Please observe below images.

    workflowProperties.Item["CurrrentStatus"] = "Completed";

    workflowProperties.Item.Update();

    Thursday, April 19, 2012 10:09 AM
  • Sure, I can build a simple application and test during break time.

    By the way, I found something for you which will definitely help you. This page contains full instruction + code snippet. Check the link below.

    http://www.bizsupportonline.net/infopath2007/set-infopath-form-field-value-sharepoint-workflow.htm


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com



    • Edited by Sangha Baek MVP Thursday, April 19, 2012 3:32 PM
    • Marked as answer by Rauf Ab Friday, April 20, 2012 9:12 AM
    Thursday, April 19, 2012 3:29 PM
  • Ohh man thank you,

    I got it what i need to do. Now everything is working fine.

    Before Mark As Answer this thread please clear my little confusion.

    1 - The code you provide in two lines below

    workflowProperties.Item["CurrrentStatus"] = "Completed";

    workflowProperties.Item.Update();

    what was the purpose of above code and what it actually do. I send you the screenshots, Can this code fit in to my scanario or not???

    2- If above code cannot fit into my scanario then is it the only solutuion that you provided me in the following link???

    http://www.bizsupportonline.net/infopath2007/set-infopath-form-field-value-sharepoint-workflow.htm

    3- If i want to restrict user to insert form in library unless its any application status (workflow status) is in "In Progress". Then how can i restrict to her? Should i use CAML query to check its application status??? If yes then when in thousands of form are inserting by users will CMAL query work good?

    I am really thankful for your help and cannot mention in words :).



    • Edited by Rauf Ab Friday, April 20, 2012 4:12 AM
    Friday, April 20, 2012 4:07 AM
  • There are several different approaches to accomplish the goal. I was trying to provide an easy approach which simply updates Library column value instead of update a field value in InfoPath form. As you can see, updating field value in the form is more complicated. Go to your form library and manually change (Edit Properties) promoted column. You will find out field in your InfoPath form also got changed.

    I think you better open a new thread with a new title in the forum regarding this question. Basically you cannot restrict a user to submit the form unless the user has a limited access. You may design your workflow does nothing but sending an email when status is in "In Progress". CAML Query would be a good option to handle thousands of items because it does not cause any unnecessary queries. 


    백상하 - Stop hacking my blog http://blog.naver.com/agilepoint
    쉐어포인트 배움터 http://sharepointkorea.com

    Friday, April 20, 2012 7:46 AM
  • Thanks sangha,

    I really appreciate your kind help on every step :).

    Friday, April 20, 2012 9:12 AM