switch to edit mode on button click - InfoPath Dev Sign in | Join | Help in InfoPath 2010 InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » InfoPath 2010 » switch to edit mode on button click switch to edit mode on button click Last post 07-15-2011 08:10 AM by leoffneym. 22 replies. Page 1 of 2 (23 items) 1 2 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 06-29-2011 12:44 PM BigMonty Joined on 06-29-2011 Posts 12 switch to edit mode on button click Reply Contact I've been working on a search form that allows users to fill out a single field and search in a list based on that field, populating other fields if results are returned. Assuming results are returned (it will always be a single record returned), I now want to switch the form over to "edit mode", where the user can update the results of their search. I tried creating a rule that switched the view to my edit form, but when i click save, it creates a new entry. Just a FYI, the new item view (with the searchable field) is called when the user clicks the New Item on the ribbon. All of the other fields are read-only until the user does the search, this is to keep from dupes being entered. From an architechture perspective, is this the way to go? Filed under: infopath 2010, Forms, edit mode 06-29-2011 01:48 PM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact Infopath doesn't work the way you are wanting it to work(out of the box) unfortunately. When you open a new form, Infopath generates a new ID(internally) for that form. Ex: You open a form (Form1), type in your data and save it. It saves as Form1 (it may be named different for you). You open a new form (Form2), and search, and find out that this data has already been entered, Form1. It pulls the info from Form1 into this form. When you hit save. This form saves as Form2. Why? because Infopath only pulled the data from Form1, it did not actually open Form1. The reason InfoPath does this is both complicated and correct in its use. There are ways around it though. Depends on if you use code or not. I am not sure in qRules can do this or not since we use custom code here. You can have a form check for data like you have now, and have it open the form with the data, edit the data, then close when you save. Ex: You open a form, type in your data, then save. It becomes Form1. You open a new form and search, it find that Form1 is match. The open form can then open Form1, which you can then edit, and save as if you opened from sharepoint. when you save Form1, it will close itself like normal, and you can either keep searching or close out of the open form. Just remember, this requires code to be done and cannot be done if the form is web based (opens in the browser, browser based forms do not work the same) If this sounds like something you are interested in, let me know. I use it here extensively to cross-link forms and make them communicate when they are opened to prevent duplication. G Moore 06-29-2011 04:48 PM In reply to Patrick Halstead Joined on 08-08-2006 Posts 5,112 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact Maybe I'm missing something, but why not just create conditional formatting for the controls based on a hidden value in the form, for example a field called "editability". By default the hidden "editability field is false. Add the formatting rule to every field except the one you are using to search - the rule is that if editability is false disable the control. Add an action after the query to set editability to true. Should be easy. Patrick HalsteadProject Manager at Qdabra 06-30-2011 05:49 AM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact Updating the way you are thinking Patrick would work if they are using a database, but if they are using sharepoint forms(xml), it won't work since InfoPath has to save the xml back into sharepoint. So I guess the question to the OP is: Are you using a database or a just sharepoint xml forms? 06-30-2011 07:07 AM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact thanks for the responses, very helpful! a little background, I'm a total IP newbie, and have only been using SP for a couple of months now, so I'm still learning all of the jargon. With that said, I do have a lot of web development experience so coding is not an issue if I need to go that route. I *think* I'm using browser based forms, as I embedded the form I created into a web part on a custom aspx page I created, and I'm saving the data to a SP list. I originally wanted the user to click the NEW button in the ribbon, have that pop up my custom search form, have the user do a search and depending if a record was returned, edit that record and save it back to the list. This doesnt seem do-able, thats why I created the custom aspx page and figured I could either switch modes or create 3 forms, one for search, the other two for insert/update. Would this be the way to go? Thanks for helping out a newbie!Josh 06-30-2011 01:55 PM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact You could do all this in one form. 3 different views: New Item/Check for existing Item VIEW Insert Item VIEW Update Item VIEW When the user opens a NEW form, its would give them the New Item/Check for existing Item VIEWThis would be where they could insert there first info, maybe a number, a name , etc.When they enter it and click the button to search, based on if the item is NEW or EXISTING it would choose either the Insert VIEW or Update VIEW, respectively If it is the Insert View, you already know how to do that. If it is the Update VIEW, you can do one of 2 things either import all data from the existing form into this one so that when you click save, you are essentially saving the existing form again (can explain more if need to) or open the existing form in its own window, edit it and then save it. This works when using sharepoint and xml and your storage. Why one form?The entire process can be controlled by one form, so why not. You can use three forms, but you will end up recreating the same info for two of them. 06-30-2011 03:26 PM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact this was the approach I initially thought was the best, and I even got my form set up to switch to the appropriate view after the search. The problem was when I went to edit a record and save it, it created a new record anyway, instead of updating it. My data connection was set to pull all of the records, as I didnt have any filter on it (the only time I did filtering was on the search button click). Any idea what I may have done wrong? 07-01-2011 05:13 AM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact How do you have InfoPath naming the files that are saved into sharepoint? Are you choosing the names and designating a field to be the filename or letting InfoPath auto-create a name? 07-01-2011 07:41 AM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact SP is doing THe naming 07-01-2011 11:43 AM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact When you save the forms, are you using a data connection or the submit button geneterated by submit options. (if using the submit options, go into data connections to find out the data connections name, may or may not have "submit" in its name)Go into the data connection and make sure the Allow overwrite if form exist is checked. (if this isn't checked, it will create a new form) You can create a field name filename. Using the data connection, you can select filename as the "filename" to be saved as.When you search and find an existing form, you can set the filename field to the filename of the existing form, then use a button that submits using a data connection, select the submit data connection you found above. Now when you open and search, you can edit the existing and when you save, you will be saving over the old existing form, essentially rewriting it. You will have to clear some fields before saving though, such as the field you entered the first info into when searching, its not necessary, buts it helps so that the next time you open that form from sharepoint, only the necessary fields are filled. 07-04-2011 12:48 PM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact >>>>> You can create a field name filename. Using the data connection, you can select filename as the "filename" to be saved as.When you search and find an existing form, you can set the filename field to the filename of the existing form, then use a button that submits using a data connection, select the submit data connection you found above. just out of curiosity, are you talking about a document library here? I'm not using one, I'm using a straight up SP list, should I convert it over to a document library? 07-05-2011 05:22 AM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact No you don't have to. That just makes things more complicated. In order to update a SP list, you will have to a CAML update. It requires more overall work, but can accomplish the same thing. I assumed you were using forms, but it makes no difference which you use. 07-05-2011 06:33 AM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact still being a IP newbie, is there a "preferred" way of doing this? or maybe a better term would be "standard"...anyways, do you have any examples for doing CAML updates? or should I convert this over to a document library? happy (late) 4th :) 07-05-2011 09:04 AM In reply to leoffneym Joined on 08-06-2010 Posts 81 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact The way you save the infomation depends on how it is used. EX: We track documents from begining to end, with internal archiving happening within the form itself. This has to be self contained within one form, or you would end up with a SP list thanks extremely long and not really easy to read. In your case, it sound like your using the SP list like excel, which make the way your using IP work great. I would leave your form as is and just build in CAML updating. To do CAML: When you created the SP list and added new columns did you change the names of any columns after they got created (Ex: Title is the first column when you create an SP list, did you rename it?) You will need the original names of the columns to use CAML. There are some programs mentioned here that hepl you get the orignal column names. This is the one i use -> here. Once you download it and get connected to you sp list, you can ues it to get the original column names. (When connecting, use Connect via SharePoint Web Services, 9 out 10 times you wont use Object Model) Find your SP list in the Lists on the left hand side. Then select New Query from the right hand side. Once you have that, you can get the names. The outline in red will give you all the columns in yout SP list in there Original names. Write them down or keep this window up. To write the actual CAML -> http://www.infopathdev.com/blogs/matt/archive/2006/02/02/Add-SharePoint-List-Items-with-InfoPath.aspx Where it says Field Name, enter the column names from above, in order that they appear above, all of them.(Even if you are not changing a column, you still want to add it now, so you don't have to add it later) The other thing to change is <Methed ID="1" Cmd="New">, change the Cmd="New" to Cmd="Update". This will make sure that you update and not add a new item. Follow all the other steps in the link. it will get you setup so that the CAML works. Test the CAML as well with test items. If it doesn't work, check the column names, they have to be exact.(took me a week to get it work, because its not really defined how to use CAML correctly anywhere, the link is nice, but it assumes you know more than you do) Let me know how it goes for you, its alot to do. Happy late 4th to you as well. 07-06-2011 12:15 PM In reply to BigMonty Joined on 06-29-2011 Posts 12 Re: switch to edit mode on button click Mark as Not AnswerMark as Answer... Reply Contact wow, some really good info in here, thanks a bunch! So over the last day I've been working on getting this to work, and I think I'm almost there. To simplify things, I created a new form from scratch and followed the steps outlined in the link you gave. Unfortunately, u2u doesnt work with SP2010, so it took me some time to get all of the internal names. After I got the field names, I was able to follow the rest of the steps, and when I run it in IP Filler, I am able to only add in new records. When I change the Method to Update (and then re-do the data connection to use this newly updated xml doc), it submits the form but doesnt update the record, and gives no errors. Any ideas? Page 1 of 2 (23 items) 1 2 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
I've been working on a search form that allows users to fill out a single field and search in a list based on that field, populating other fields if results are returned. Assuming results are returned (it will always be a single record returned), I now want to switch the form over to "edit mode", where the user can update the results of their search. I tried creating a rule that switched the view to my edit form, but when i click save, it creates a new entry. Just a FYI, the new item view (with the searchable field) is called when the user clicks the New Item on the ribbon. All of the other fields are read-only until the user does the search, this is to keep from dupes being entered. From an architechture perspective, is this the way to go?
Infopath doesn't work the way you are wanting it to work(out of the box) unfortunately.
When you open a new form, Infopath generates a new ID(internally) for that form.
Ex:
The reason InfoPath does this is both complicated and correct in its use.
There are ways around it though.
Depends on if you use code or not. I am not sure in qRules can do this or not since we use custom code here.
You can have a form check for data like you have now, and have it open the form with the data, edit the data, then close when you save.
Just remember, this requires code to be done and cannot be done if the form is web based (opens in the browser, browser based forms do not work the same)
If this sounds like something you are interested in, let me know. I use it here extensively to cross-link forms and make them communicate when they are opened to prevent duplication.
G Moore
Maybe I'm missing something, but why not just create conditional formatting for the controls based on a hidden value in the form, for example a field called "editability". By default the hidden "editability field is false. Add the formatting rule to every field except the one you are using to search - the rule is that if editability is false disable the control. Add an action after the query to set editability to true.
Should be easy.
Updating the way you are thinking Patrick would work if they are using a database, but if they are using sharepoint forms(xml), it won't work since InfoPath has to save the xml back into sharepoint.
So I guess the question to the OP is: Are you using a database or a just sharepoint xml forms?
thanks for the responses, very helpful!
a little background, I'm a total IP newbie, and have only been using SP for a couple of months now, so I'm still learning all of the jargon. With that said, I do have a lot of web development experience so coding is not an issue if I need to go that route.
I *think* I'm using browser based forms, as I embedded the form I created into a web part on a custom aspx page I created, and I'm saving the data to a SP list. I originally wanted the user to click the NEW button in the ribbon, have that pop up my custom search form, have the user do a search and depending if a record was returned, edit that record and save it back to the list. This doesnt seem do-able, thats why I created the custom aspx page and figured I could either switch modes or create 3 forms, one for search, the other two for insert/update. Would this be the way to go?
Thanks for helping out a newbie!Josh
You could do all this in one form.
3 different views:
When the user opens a NEW form, its would give them the New Item/Check for existing Item VIEWThis would be where they could insert there first info, maybe a number, a name , etc.When they enter it and click the button to search, based on if the item is NEW or EXISTING it would choose either the Insert VIEW or Update VIEW, respectively
If it is the Insert View, you already know how to do that.
If it is the Update VIEW, you can do one of 2 things
This works when using sharepoint and xml and your storage.
Why one form?The entire process can be controlled by one form, so why not. You can use three forms, but you will end up recreating the same info for two of them.
How do you have InfoPath naming the files that are saved into sharepoint?
Are you choosing the names and designating a field to be the filename or letting InfoPath auto-create a name?
SP is doing THe naming
When you save the forms, are you using a data connection or the submit button geneterated by submit options. (if using the submit options, go into data connections to find out the data connections name, may or may not have "submit" in its name)Go into the data connection and make sure the Allow overwrite if form exist is checked. (if this isn't checked, it will create a new form)
You can create a field name filename. Using the data connection, you can select filename as the "filename" to be saved as.When you search and find an existing form, you can set the filename field to the filename of the existing form, then use a button that submits using a data connection, select the submit data connection you found above.
Now when you open and search, you can edit the existing and when you save, you will be saving over the old existing form, essentially rewriting it.
You will have to clear some fields before saving though, such as the field you entered the first info into when searching, its not necessary, buts it helps so that the next time you open that form from sharepoint, only the necessary fields are filled.
>>>>> You can create a field name filename. Using the data connection, you can select filename as the "filename" to be saved as.When you search and find an existing form, you can set the filename field to the filename of the existing form, then use a button that submits using a data connection, select the submit data connection you found above.
just out of curiosity, are you talking about a document library here? I'm not using one, I'm using a straight up SP list, should I convert it over to a document library?
No you don't have to.
That just makes things more complicated. In order to update a SP list, you will have to a CAML update. It requires more overall work, but can accomplish the same thing.
I assumed you were using forms, but it makes no difference which you use.
still being a IP newbie, is there a "preferred" way of doing this? or maybe a better term would be "standard"...anyways, do you have any examples for doing CAML updates? or should I convert this over to a document library?
happy (late) 4th :)
The way you save the infomation depends on how it is used.
EX: We track documents from begining to end, with internal archiving happening within the form itself. This has to be self contained within one form, or you would end up with a SP list thanks extremely long and not really easy to read.
In your case, it sound like your using the SP list like excel, which make the way your using IP work great.
I would leave your form as is and just build in CAML updating.
To do CAML:
When you created the SP list and added new columns did you change the names of any columns after they got created (Ex: Title is the first column when you create an SP list, did you rename it?)
You will need the original names of the columns to use CAML. There are some programs mentioned here that hepl you get the orignal column names. This is the one i use -> here.
Once you download it and get connected to you sp list, you can ues it to get the original column names. (When connecting, use Connect via SharePoint Web Services, 9 out 10 times you wont use Object Model)
Find your SP list in the Lists on the left hand side. Then select New Query from the right hand side.
Once you have that, you can get the names.
The outline in red will give you all the columns in yout SP list in there Original names. Write them down or keep this window up.
To write the actual CAML -> http://www.infopathdev.com/blogs/matt/archive/2006/02/02/Add-SharePoint-List-Items-with-InfoPath.aspx
Where it says Field Name, enter the column names from above, in order that they appear above, all of them.(Even if you are not changing a column, you still want to add it now, so you don't have to add it later)
The other thing to change is <Methed ID="1" Cmd="New">, change the Cmd="New" to Cmd="Update". This will make sure that you update and not add a new item.
Follow all the other steps in the link. it will get you setup so that the CAML works.
Test the CAML as well with test items. If it doesn't work, check the column names, they have to be exact.(took me a week to get it work, because its not really defined how to use CAML correctly anywhere, the link is nice, but it assumes you know more than you do)
Let me know how it goes for you, its alot to do.
Happy late 4th to you as well.
wow, some really good info in here, thanks a bunch!
So over the last day I've been working on getting this to work, and I think I'm almost there. To simplify things, I created a new form from scratch and followed the steps outlined in the link you gave. Unfortunately, u2u doesnt work with SP2010, so it took me some time to get all of the internal names. After I got the field names, I was able to follow the rest of the steps, and when I run it in IP Filler, I am able to only add in new records. When I change the Method to Update (and then re-do the data connection to use this newly updated xml doc), it submits the form but doesnt update the record, and gives no errors.
Any ideas?