Get a SharePoint InfoPath form to load in the browser from a task - sharepoint

I've published an InfoPath form, through the administrator route, to a document library. I can click new form on the document library and have my custom form load up in the browser. When the filled form is saved back to the list it fires off a workflow. The workflow creates a task for another user to go into the form and complete the missing fields (if there are any.)
The key here is that the partially filled form saved to the library needs to be the very same form opened in the first task. The link field of the task is automatically filled with the url to the list item, which is the xml for the partially filled form. The link is identical to that when you mouse over the item back in the document library but when it's clicked from the task it try's to open the form inside InfoPath itself and not inside the browser. So that's one problem with the link field that SharePoint automatically populates when you create a task.
Ideally I would want to associate the partially filled form with the task itself. I've done this before in workflow with infopath forms by putting the FormURN inside workflow.xml and then specifying the TaskType on the task. However this will create up a new form based on the template. How can I get it to use the existing xml on the list item which the workflow which the task is actually running on.
Suggestions would be very much appriciated.

Change the url to go this url
{SITE_COLECTION_URL}/_layouts/FormServer.aspx?XmlLocation={FORM_URL}&DefaultItemOpen=1

use the tutorial on this page and have a field on the forms ItemMetadata.xml called url and set it in the code
taskProperties.ExtendedProperties["url"] = SERVERURL + "/_layouts/FormServer.aspx?XmlLocation=" + FORMURL + "&DefaultItemOpen=1";

This is not the most elegant solution but does work well. You will need to modify the form to act as an action listener.
Instead of creating tasks, send out emails containing a link to the InfoPath. When the user opens the form customize the top of form to look like a task form with a checkbox, when the form is updated fire the workflow to check if the check box is complete, if so move on the workflow on.

Related

Why is the wrong form opening when I click the doc link I created from a SSJS function?

Ok, this is weird. I created an xpage input form. After the form is filled out, a document is created. I then create an email to notify people that the document has been created. I drop a doclink to the newly created document in the body of the email. During testing, I noticed that when I click the link in the email, the wrong Notes Form is opened. Instead of the 'TrainingRequest' form displaying the fields, the form 'Feedback' opens up instead. Here's what I checked:
- On the xpage data section, the 'form' is set to 'TrainingRequest'.
- When I open the document via the doc link, the field 'form' has the value 'TrainingRequest', which is correct. Yet it's displaying the 'Feedback' form.
- When I check the other field properties of the document, all the correct fields from the 'TrainingRequest' form are there and populated correctly.
- When I open the document via the view, the correct Notes form 'TrainingRequest' opens.
- There is no default form in the database design.
Has anyone seen this before?
thanks
clem
Doc links are always created using the default view of your application. If there is a form formula in this view then this overrides the form in the document. Remove the form formula of the default view and it works.
I almost NEVER use form formulas in my application because of the side effects.
Source code would be useful. But initial best guess based on what you're saying is you have two datasources on the XPage, neither have ignoreRequestParams set, so you're editing the same document with both data sources. ignoreRequestParams missing will ignore any properties you define.

Opening different xpages forms from a view panel

I have an Xpages application that pulls data from another .nsf file. I have a view panel linked to a view in that db. The view has documents with several different forms in it. I want to be able to open each document in it's own form(xpage).
How do I write a computed At Runtime, open selected document using: statement that will select the correct Xpage to present the document.
If you use the Data View component instead of a View Panel, you can compute the pageName attribute, referencing the var attribute to return a different value for each row based on the document that row represents. The flexibility of the Data View component also makes it easier to make your app look more like a modern web application and less like an Excel spreadsheet. As an additional bonus, the mobile theme invokes a renderer that makes each Data View instance look like a native mobile list, so using Data Views instead of View Panels simplifies mobile development.
You have 2 options:
use "use xpage associated with form" and edit the form's property
use a SSJS formula to compute the Form. You provide a variable name in the view control var to access a view row as XSPViewEntry. If the Form is in a view column even one you don't display you use .getColumnValue otherwise getDocument.getItemValueString
Does that work for you?
Maybe this mothed can help you: Unable to get document page name for
Hope this helps
Mark
I had a similar problem today. I use only one form but 3 different xpages for associated with this form. I have 3 different document types in the view. I used rowData the get the type of the document.
try{
var v=rowData.getColumnValue("form");
if(v.indexOf("x")> -1){var page ="x.xsp"}
else if(v.indexOf("y") > -1){var page = "y.xsp"}
else{var page = "z.xsp"}
}catch(e){
var page = "x.xsp"
}
So to your view you can create a column with the value of the form and you can use it.
I have used the extension library Dynamic View control which has an event you can code to get a handle to the NotesViewEntry which was selected. See the demo database page Domino_DynamicView.xsp and the Custom Event Handler tab for an example.
Note, in 8.5.3 (I have not upgraded yet) if you add or edit the eventHandler for onColumnClick it will be added to the XPages source as an xe:eventHandler. It needs to be an xp:eventHandler to work. The way to do it is to copy the code in the source from the exiting event and delete it. Recreate the event and update the code. Then go back into the source and change the tags within the eventHandler to xp:.

Sharepoint 2010 and DispForm.aspx and adding custom

I am looking to add either a button to the ribbon or adding a form action button control to a list item display form.
I would like to user to have the ability to email the detail of the list item currently being view.
So far....
I created a new DispForm.aspx ...and then added the form action button control. I set the action to a custom action....then SP2010 created a new Site workflow.
I can edit this workflow..but I do not get fields for the "Current Item". I think this has something to do with the fact that its a site workflow and not a list workflow.
I also tried to edit the code in the DispForm.aspx to change the GUID of the workflow in an attempt to start a list workflow with the button.
help?
What I did to get this setup is first create a list workflow.
All work below is done in SharePoint Designer. And I did not edit any pages just created a custom action that showed up in the ribbon.
You can do this by selecting list and libraries from navigation then selecting the list you want to add the workflow to. Once you select that there should be a "block" for workflows just click add a new workflow. With that you can design your workflow and you will have access to current item.
Once you are done with the workflow find the Custom Actions block on the List page (It is below the workflows block for me). Click some where in the block and on the top ribbon you should see Custom Action. When you open up that menu it gives you the option to select the type of action (Ribbon, DetailView, ...). Now just link it to your workflow you just created. (You may have to refresh the list to get the workflow to show up. If it still doesn't show up make sure you published it).

Modifying sharepoint edit dialog

I have successfully created a feature in sharepoint that modifies the existing edit dialog and adds a custom button to it like this.
and I am aware that I can pass back data when the user clicks the custom button like this.
<CommandUIHandlers>
<CommandUIHandler Command="ActivateUser" CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}" />
</CommandUIHandlers>
As detailed here
I can now handle the list item and perform my required actions on it BUT given that this button has been added in the modify context (IE: Inside the sharepoint edit item dialog) what if you want to save changes to the data itself?
To me it seems like using your custom button would always mean losing any changes the user has made to the data. Is there a way around this?
Good question!
You actually already linked to the solution: Right now you are simply redirecting the user by using a URL as your CommandAction: CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}"
This if course redirects the user to another page without saving the current entry. What you want to do is use Javascript as linked in the MSDN article:
CommandAction="javascript:alert('here be dragons');"
You can either work the the SharePoint Javascript object model here and use something like SP.ListOperation.Selection.getSelectedItems(); or you could use complete custom code.
From your aspx page name I can see you want to "make a use active" (btw: wouldn't "ActivateUser.aspx" be nicer?). If this simply means setting a property in another list you could do that with the SharePoint OM, if it is some custom stuff you would need a webservice which you can call from JavaScript and "activate the user" like that. You can of course always access the current form and pass on the values the user entered. Or you could create a custom save button which does some stuff (activate user) before saving.
Lastly: You can also have postbacks in your custom button where you could do anything you'd like.

SharePoint Dataform webpart redirection issue

I have two web parts in my sharepoint aspx web page. One is Content editor web part and the other is data form web part.
In data form web part, I have a data view and I need to pass a parameter "id" to this dataview which will show the project details in the data view. I tried to use a value from a control as a parameter and never had a success. I did googled a lot last few days and haven't found any solution. It would be great, if someone show me a way to use the text from a control (may be a text box or select control). if someone have a working sample, please share. Alternatively I have used a query string as a parameter (eventhough I prefer to use text from a control). We need to pass a query string called id. For example, I am navigating to http://localhost/pages/1.aspx?id=7. This will show the project details of project id 7 in data form web part. this works fine.
I need to provide an option to user to enter the project id instead of modifying the query string in url. To achieve that I used content editor web part and I have a text box text1 and a submit button (html controls). The user will enter project id in the text box provided and will click the submit button to view the project details in dataview. The submit button javascript code has the following code:
url = 'http://localhost/pages/1.aspx?id=7';
alert (url); //alerts as http://localhost/pages/1.aspx?id=7
window.location = url;
For testing purpose, I just hardcoded the url. However, clicking the submit button is not redirecting to http://localhost/pages/1.aspx?id=7 or something happens during redirect. The page just reloads once. i.e., if I am in http://localhost/pages/1.aspx?id=12 and clicking the submit button reloads the page http://localhost/pages/1.aspx?id=12 instead of navigating to http://localhost/pages/1.aspx?id=7.
Without data form web part, the redirect works fine. Kindly help.
Thank you

Resources