qRules - Submit To Multiple InfoPath Lists

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi my name is Hillary stupa and I'm a developer with Cadabra software today I'd like to show you how to work with cue rules in your form and submit data to multiple SharePoint les we're also going to update list items from our form here's the form I'm going to be working with today now this form already has some basic logic in it we have a customers field and this customers field has data provided to it by a SharePoint customers list there's an order filled the order field has data provided to this drop-down from an orders list in SharePoint I'm using a Northwind SharePoint template so some of these customers and orders might look familiar to you if you've worked with Northwind over the years using Microsoft products what I'm going to do with this form is I'm going to modify it using cue rules so that we can actually edit items that we've selected or add new items to our SharePoint list so let's preview it and I'll show you what's currently in place now currently my form just has two little dropdowns on it this first one selects a customer when I select a customer my orders list is queried I'm using SharePoint 2010 so I have query fields and I'm just running a query to get back only the orders I need so all of these orders are going to apply just to this particular customer if I have a customer selected and I click my edit button then these are some main data source fields that I'm populating with customer information so that I'll be able to eventually modify them and save those changes back to SharePoint and if I change the customer to blank and then click my edit button you can see I've got blank fields that I could possibly fill out and my intention is to when I fill out a blank customer and click Save to save that new customer or to be able to edit an existing customer from these fields and I'm just copying the data directly into those fields when I click this button I also have this order field same kind of logic when we select an order here if I click the button that an order selected it copies in the information from that particular order as you can see this is real to this particular customer some of my fields here are dropped down so that I can change those to make editing a little bit easier I think probably I wouldn't want to change the customer but it gives you the general idea and if this were a blank order instead and I clicked my edit button I would just have blank fields to fill out now right now my save buttons they don't do much they just set the fields in their respective sections to clear and set the field that I'm using for my conditional formatting to show and hide this section back to blank so that my section will hide appropriately so I have no complex logic in this form right now at all and what I'm going to do is I'm going to go ahead and close my template and inject it with cue rules so that we can start adding some some more intricate logic I've opened up the cue rules injector I've navigated to my form file and I'll click the inject button again you want to make sure your form file is closed when you inject cue rules because cue rules is adding some things to your form template to do that it needs to be able to unpack your form of source files and pack it back up with the new data connection the code DLL and so forth we get a little message about being sure we backup it's something you might want to pay attention to you may decide that you don't want to use cue rolls in your form so before you inject if you save a copy that makes it easy for you it is possible to manually remove cue rules however if necessary so we inject it successfully I'm going to ahead and close these things up and then I'll open my template up again in design mode so back in our template we can see that we now have a cue Dabra rules data connection and that key rules has been injected into our form so let's talk about what I'm doing here with my logic right now I've got some rules on my edit button that I can either I'm simply setting a fields value this is a field in my secondary data source that I'm using for showing and hiding this particular section and then if a customer's been selected customer is not blank then I'm setting the values of these fields in here to the values from my secondary customers data source it's this guy right here so I'm selecting my selected customer based on an XPath filter so if we take a look here you can see I'm selecting the company name where the ID matches my selected customer so I'm filtering my XPath to get back the correct customer so I'm setting all of these values in my main data source and the reason I'm setting them in my main data source is because Q will submit to SharePoint list works using main data source fields we're going to have to create a mapping for both of these sections the ad customer and the ad order we'll be creating two mapping files for those two items you'll notice I have a field here called SHP ID and I'm using this field because I want to be able to run updates I'd like to be able to use a my queue rules submit to SharePoint lists to update items in my list as well as add new items so we'll talk more about that when we actually put our command together for now let's get our mappings created first so this is a full trust form that comes with queue rules there's installation instructions for this form in your user guide I think it's at about page three it talks about installing these full trust forms I've already got mine installed and I'm gonna click on the find mapping the first thing I need is I need the exits and the template file that I'm working with so I will navigate to that and attach it and now I need to enter the route to my SharePoint site and we click the get SharePoint lists button so I've got my list the first list I need to map is I need to map my customers list and I'm gonna click the extract schemas button now in this instance I'm not working with repeating data my my data node in my form that I want to be able to submit back to this list is just a single node my user can add a customer a single customer at a time or they can update an existing customer a single customer at a time that's the structure I've chosen for this forum if my add customers node which you can see in this forum if my add customer node was repeating because I was going to allow them to edit or update multiples or add multiples then my structure would be different here in my mapping and I would select this checkbox as it stands my data is not from a repeating group so I'm not going to worry about that so I just need to add my mappings now I pointed out that SHP ID field we don't need to map that because queue rules takes care of that queue rules we'll watch for we will tell queue rules in our command which field has the ID so that doesn't need to be mapped we need to map a few fields though we need to map our name our company ID which in this list is something like the first five or six characters of the customer name and we need to map our contact name those are the fields I've decided in my form I'm going to require the user to fill out if they're creating a new customer so first we select name and you can see the XPath the full XPath is added there and I'll go ahead and I'll select my field that I'm mapping to we add a mapping we click the button we extract we expand the schema and here's our company ID and we'll select company ID which is I think from my list customer ID as you can see these things don't have to match that's why we create a mapping file and so from here we go ahead and we select one more and this one is going to be our contact field and I'll select contact name now we're going to save our cue rules mapping and I'm going to go ahead and I'm just going to name this one customer mapping there we go and now I need to create a second mapping for my orders so what I've done is I went ahead and I just changed the list here in my SharePoint les I extracted schemas again and then I mapped all of the fields that are in my add order section I've already saved this as a cue rules mapping and I called it o Rd mapping so I've got the two mapping files that I need for my next task and I can go ahead and close this form the next thing I'm going to do is I'm going to add my mapping files as resource files to my forms so that's under the data tab here and you can see I've already got this form logic XML which I'm using for a secondary data source for things I don't want to clutter up my main data source with and then there's the cue rules I Cemil so I'm going to add my two new XML files and now you can see I've got both of those added here next I need to add data connections to those XML files I just added to receive data connection XML document it's in my resource files here's my customer mapping and I'll just go ahead and say ok there and I'm going to leave this name and I'm going to leave this checkbox selected because I want to retrieve data when the form is opened and now we add one more for our second mapping file and again leaving the name as it is and leaving this checkbox selected we're going to need to add to submit data connections both of these are going to be the same web service it's just when we set up our submit data connection we specify where the submit data connection will find the values it needs for its parameters and since we're submitting to two different lists we have to have to submit connections set up one for each of our mapping files so we'll do that next I'm going to just add a data connection it's going to submit data and this is to a web service now this is going to be the update list items method of the lists web service so it's basically your SharePoint Server followed by underscore VT i underscore bin /list ASM x and then we just have to search through here and we find update list items here's the one we want we click Next now here's where we're going to decide which mapping file we want to use I'm going to use my customer mapping first so to get my list name I need to navigate to that data source and the list name is right here in the list collection node and I'll say okay I leave the rest of this as is and now for updates I select the batch node also in the custom a ping here and I say ok this time I'm going to change that to XML sub tree and I'll select next and now I'm going to name this one cust to submit so I can keep these sorted in my hat I'm going to deselect that because I'm not concerned about a default submit connection right now and I'll say finish now I'm going to do the same thing again for my order mapping so we add again and it's submit data web service I save that URL on my clipboard we click Next again it's update list items method we click Next now this time I'm going to select values from my order mapping and it's list collection for the first side up the second parameter is going to take the batch node also from my order mapping in since I will change this to XML substrate okay and again I'm going to deselect this just because I'm not concerned about that right now and I'm gonna call this order submit so now I have two mappings I've got custom a ping and order mapping I've got custom it and order submit and I'll want to keep track of these names I'm going to need these for my cue rules command I tend to generally take a quick screenshot and then use that to help me keep track of things next we need to take care of setting up our cue rules command for submitting to our SharePoint list let's take a look at the syntax for that command in our user guide so here's some examples of the syntax and the syntax we're going to be using today is this one we're going to include the command of course which is submit to SharePoint list the submit parameter the mapping parameter and we are going to include the ID parameter in this instance because we want to be able to update items that are existing what I've done is I copied in the sample command syntax that I'm interested in as well as the XPath I need for my two different ID fields so that I can create my command here in notepad it's just a little easier for me to do my editing here sometimes the InfoPath formula windows don't give you a very much room to type in a value so for our command I am going to be using submit to SharePoint list my first one is to submit my customers so it'll be submit equals and I named that CU st submit case matters it is case sensitive so i used caps on both custom submit must submit connection my mapping file is cust mapping again case is important it was a lowercase C and a capital M for that and then I need my ID field now I didn't map repeating data so I don't use a relative path to my ID field in fact I use the full path to my ID field so here is my first command for submitting my customer data submitting my order data if the command is going to be very similar what's going to change is this is to be order submit this is going to be order mapping Ord mapping and this instead of ad customer it's going to be ad order okay so that all looks good now I've got my commands ready to go so I'm going to put them in my form so we can try them out I'll do the customer command first now generally when I'm working with key roles I do a little at a time so I try one command first and then I add my next one so we'll we'll take that approach here as well so where my logic should go here is on my Save button and I've already got some logic here to hide my section when I save and to clear my fields when I save so I'm going to go ahead and just add a new rule I want to move that up because I'd like it at the top and I'm going to call this submit to SharePoint okay and we'll go ahead and add our command whoops wrong item change that Miss set a fields value now the command actually takes care of the submitting so all you have to do is set the command and the command is going to do everything else it's going to execute that submit connection so you don't have to worry about it and it's going to populate your list with the item you've just submitted if you have an ID in this ID field that you've specified it will update the existing item so we're either going to create a new item or we're going to update an existing item say ok and let's give this a try we're going to try both both methods we're going to update and we're going to create a new so we'll preview this form we'll select a customer I mean it's like the customer at the top of the list just because it'll make it easier for us to find in our customer lists on on SharePoint and I'm going to click Edit now I add the little logic here that if the customer was already existing that we couldn't change the company ID because it struck me that that was something we probably shouldn't be able to change but let's say that our company contact here change and Maria Anders got married her new name is Maria Andersson and these folks have added an LLC to the end of their name we'll click our Save button now one thing to be aware of is we are using a submit data connection here since we're using a submit data connection we have to make sure our forms in a valid state so if you have fields that cannot be blank or things of that nature you're going to need to think that through when you set your form up if you want to do things like submit to a SharePoint list partway through the process queue rules does have a clear heirs command that you can use that can help you with that but it's just something to keep in mind now there's a couple things I didn't do here that I should have one is I should have put the queue Dabba rules air node onto the form so I could see whether or not there was an error instead we're gonna do this the the trial in air way and we're just gonna go check our list and see what happened and so here we are we're out our customers list and as you can see the company name has changed we've now got an LLC at the end of it and our contact name is now Maria Anderson I'm going to change our form now and we're going to add a new customer so we'll just set this back to blank and now we'll click on our button for editing or adding new so I am going to make this customer and company start with an A - so it's easier for us to find in our list so this company is going to be aardvark importers this is our new company and our company contact is going to be Albert and our company ID is going to be a a our D and I'm going to click Save and let's go look at our list here we're going to need to refresh and after resore ting so that we've got our A's on top you can see I had been sorted by ID here's our new customer of aardvark importers so the next thing I want to do in my form is I want to add to these rules so that I'm also reek worrying that customers data source so that my new entry shows up in my drop-down after I add him we'll add that here to our Save button after submit to SharePoint command will just add a new action and it'll be query for customers and we'll go ahead and we'll query for data and we're going to use customers for our data source and we'll say ok now you can add some conditions here we could check the queue rules air node make sure our data had submitted successfully this would be a great place to add some air handling we could check the queue rules success node make sure it was true either one of those would be great you may not want to require you for customers if there was a failure with your SharePoint submit for some reason as I mentioned earlier I should have before we started previewing put the air node on my form so we could have seen if there were any airs but fortunately there haven't been just a false alarm because I had things sorted by ID so let's go ahead and preview again and we'll try our logic once more so we can see now when we click our drop-down that aardvark importers is listed here our list is sorted by ID right now we could change that in the info path when we walk through the data connection and sort by name instead right now we're sorted by ID so anybody new we add is going to be at the bottom and we can see that our first sentry here has an LLC again and so we'll go ahead and we'll edit him again since he's easy to find and we're gonna get rid of Moorea all together and have wescam's work there instead I'll click Save now what's fun here is because our customer drop-down is using the ID for the value you can see our refreshed value is already showing there so I've previewed my form again this time I've gone ahead and I've gotten that data source sorted so that it's coming back in alphabetical order it'll make it easier for us to find our new item and this time I'm just going to add a new customer directly I'm going to say well there's nothing here that is my particular company and so this is going to be a triple-a auto supply and we'll call it a AAA for our company ID and our company contact is going to be Alfred and we save now another option we could have is unsaved we could automatically set our customer field to the new ID for the customer we just created so that's an additional piece of logic that could easily be added why don't we do that real quick if you look at the rules I've got on my Save button I'm not clearing the fields in that section until very last so the SP ID field should be set with the value of my new customer from Q rules Q rules will return that when I create a new customer so we'll go ahead and we'll just add another rule here new action and we'll call it set customer and we're only going to run this if the customer field is blank so if the user hasn't already selected a customer from the drop-down otherwise we'll just leave that customer alone so if customer is blank let's say okay and we'll add and we'll just set a fields value after this we'll do the orders I just wanted to kind of walk through some of the fun things you can do here since we've got this Q rules logic in place for the customer and the fielder group we're going to add is this will just say okay okay okay and we're gonna preview once more we'll add a new customer and this time what's going to happen is our customer drop-down well auto magically gets set to our new customer for us this time I'm not concerned about starting things with a because it's going to be pretty pretty easy to find and we're gonna make our new company info path detailing incorporated and we'll give it an idea of Ind e and I'll go ahead and be the company contact this time I'll spell my last name right and everything maybe there I got as well right okay so now this time when I click Save what's gonna happen is we're going to submit to the SharePoint list our new items going to get out into the SharePoint list and our customer up there is going to get set to this new item so we click Save and you can see that our customer is now set to InfoPath detailing and in fact that will be in our list if we go check our list along with all of the other items we've added or edited so at this point we know how to add a new customer we can edit an existing customer so let's add some functionality for orders we've already got our queue rules command written up here we wrote them both up at the same time so let's copy that and we'll add a new rule and we'll just go ahead in the set of fields value here oh we've got the value on the clipboard I'd say okay and I'm gonna go ahead and move that up so here's our rule that's going to submit to our SharePoint list and since we already know what we need to do rule wise let's add another rule to query for orders and a third rule that will set that order field if it's blank we kind of worked out our logic on our on our customers section so so we sort of know what we're doing now so let's add a new action and this will be query for orders and we'll just add a query for data we're gonna query using the orders we'll say okay now in the orders datasource when we change customers this query field for customers already getting set so it is only returning things that are from that particular customer as far as orders go and we'll just add one more action and we'll call that set order and we'll only do this if the order field is blank so if we'll set of fields value and the value is going to view this SharePoint ID where we will have our new SharePoint ID for our new item after our key rules submit has finished we'll say okay we'll say ok so now our form should be pretty much fully functional as long as we don't have any issues or errors with our new commands so we'll preview it and take a look in this instance I don't want to select any of my new customers right yet we'll select somebody that we know has orders already so we've selected a customer who has some orders now in this case I'm using the order number which probably doesn't have a lot of meaning but I didn't have another field that was easy to pick from so I just used the SharePoint ID you can see we've copied in some information from our order and if we want to check our SharePoint list and verify that this is the correct order we can so here's my orders list I've sorted it to just show this customer and we can see that order ID 3 5 2 does correlate with order number 10 5 9 9 so let's go ahead and update it let's change the employee who took the order let's say that we want Nancy to have taken that order instead of Michael and we're going to change the shipping it's gonna go via speedy Express instead of federal we'll save our changes and then we'll return here to our list which will refresh and as you can see our orders been changed and now Nancy is the employee for the order and speedy expresses who were shipping via instead of federal shipping back in our form if we click our edit button again will see that the refreshed data has been returned to our main data source section where we're storing our values when we edit them let's go ahead and create a new order for one of our new customers who doesn't already have any orders so we'll use our Triple A auto supply and you can see I've got a rule on the customer field when it changes to clear the order field and so from here you can see we don't have any orders available for Triple A auto supply so let's create one we'll need to give it an order number now in a real-world scenario you'd probably need some kind of logic to make sure you weren't duplicating an existing order number in this case I'm just going to use five nines I feel pretty confident there's nothing that high the customer is going to be Triple A Auto Supply we can add some logic there so that that's automatically selected we'll do that after we fill out this first order it's going to be Janet and we'll just go ahead and say we've got some order dates and required dates we're shipping the United package and we could add some information here so that when we selected the customer we filled this in from our customers list as well which would make great sense so we might we might do that as well we'll go ahead and just leave those things blank for now and click Save and as you can see we now have an order number which indicates success for us but let's go double check and here's our new order for our customer that we created earlier via the forum there's some things that could be done here to optimize logic for example instead of having just a Save button you might want to save in a cancel button so it's easier for the user to cancel out perhaps this order number shouldn't be something the user has to fill in perhaps it's something the form logic takes care of for the user but the one thing that I did think we should probably take care of is when we're creating a new order as long as a customer's selected this customer is already populated so I think what would make the most sense in that case is to set this field of customer when this customer field changes because after all every time we change orders here if there is an existing order it'll get populated from this data source so we don't have to worry about having an incorrect customer listed at any point in time so we'll just go ahead and add an additional rule that sets the customer field in our add order section to the customer and our main data source and we'll say ok and I think that completes most of our form logic obviously there's plenty of room for refinements there's additional things that could be done we could get all of our customer information for our ship fields when the customer is selected here we could add another data connection to the customers list and use our new SharePoint query fields with SharePoint 2010 and InfoPath 2010 to pull back just the customer data we need so there's room for enhancements but as far as the basic functionality goes this is how you can use queue rules in InfoPath to submit data to multiple lists and this also allows you to update or add new items from info path to your SharePoint list I hope this has given you some ideas for using cue rules in your own form especially when working with SharePoint there's some resources and the links at the bottom of the slide I hope you have time to check them out and be sure to post in our forum if you have any issues or questions about using cue rules thanks for watching and have a great day
Info
Channel: qdabra
Views: 11,870
Rating: 5 out of 5
Keywords: qRules, SubmitToSharePointList
Id: WftCp_EbcCU
Channel Id: undefined
Length: 29min 10sec (1750 seconds)
Published: Thu Feb 02 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.