Django Viewflow with custom views - start different flows, depending on user selection in the first screen - django-viewflow

I have a view with StartFlowMixin, it contains a form - user posts the form and a workflow starts. That works fine currently, but I need to introduce a dropdown in the form with 4 options - based on the selection in that dropdown I need to run a different flow.
E.g. the dropdown contains options like Apply for position A, Apply for position B, etc. Based on the selection the applicant needs to enter different information and different people need to approve the application.
How can I do this? One option would be to have a single workflow with a lot of ifs, but I don't like that.

The core of the BPMN approach for business process modeling is to record every user's decisions.
You could use flow.Switch for that case - http://docs.viewflow.io/viewflow_core_node.html#viewflow.nodes.Switch
Or you could use your own view, that would call required flow.StartFunction, to start actual flow - http://docs.viewflow.io/viewflow_core_node.html#viewflow.nodes.StartFunction

Related

How to display approve button for a particular user

![hierarchical structure][1]Previously we were using #functions to create forms and those forms are hierarchical structure means.
Initiator raises the form and sends to particular dept officer
Department officer approves and sends to next authority(Dept HOD) for approval
Finally, Dept HOD approves the form.
Now I want these structure in xpages. Please help me with how to create.
The general pattern of application creation hasn't changed. You show and hide information based on values in the documents. In classic Notes application you use "HideWhen" formulas using the #Formula language. These formulas work on the current paragraph.
In XPages you use the "visible" property. Clicking on the diamond shape next to visible allows you to enter code there. That code is written in server-side JavaScript.
The difference: in classic Notes a result of true means the whole row gets hidden, in XPages: the element (and all its children) is visible.
You might want to learn more about XPages following my guide and do the 27 Exercises

How should I implement `OnLoad` event handler when creating an activity using a contact?

I've created my own solution with a custom entity of type activity. I'd like to show a message whenever a new instance of it is created using an existing contact but not allow the user to create one, if only attempting to do that without going via contact.
Basically, my aim is that it won't be impossible to just create that activity (the form will be hidden directly at any attempt except for one way only). The user will have to go to contacts (or leads etc.) and in there add and create an instance of the custom activity entity. That way, I can assure that the field "regarding" will be filled out already.
I'm guessing that I need to detect somehow that the opening of the form is a creation attempt. How can I do that?
Also, as it is now, the user can't create a contact-less activity of the custom type because it doesn't appear on the menu with other activities. I must have disabled it somehow but I have no idea how. Anybody who has one?
You could do this a bunch of ways but the easiest would probably be to:
Make the regarding field read only.
Make the regarding field mandatory.
That way if a user opens a create new form they wont be able to set the regarding and because its mandatory they wont be able to save the record. When they open via an existing contact the regarding field will be mapped automatically. That said in this case just making it mandatory my be enough.
(As a side JavaScript can be used to identify the current form state, but I'm not sure how useful that is here).
In terms of where custom activities appear, by default mine show in a number of locations, for example:
CRM > Workplace > Activities > Ribbon > Other Activities > XXX.
CRM > Workplace > Activities > View Selector > XXX.
They don't show under the left hand navigation of the workplace because they are grouped under 'Activities'. I'm pretty sure these are all the default settings.
You can exercise greater control by editing the sitemap, where you can put pretty much anything, anywhere.
In addition to Mr Wood, I'd like to show you some code. It works as supposed to but I'm not sure if it's optimal.
var foo = function () {
var whatIsGoingOn = Xrm.Page.ui.getFormType();
if (whatIsGoingOn === 1)
alert("Let there be an entity!");
else
alert("Not a creation...");
}
The other states' (deletion, update etc.) numeric values are listed here.
Answering the second part of your question:
When you create a custom activity you can choose whether to have it appear in 'normal' Activity menus or not by checking the box at the top right of the entity form. This is a once-only choice as far as I know and can't be changed later.
For your setup, I would suggest NOT checking this box, so it does not appear in the activity menus to avoid users even being tempted to do it that way.
Instead, add an explicit relationship to the activity N:1 to Contact, and another N:1 to Lead. Use this relationship to add your activity to the left navigation of Contact and Lead forms, or add a grid for them (depends on how you want to use this and if you need to filter the view to something other than the default "Associated View").
When a user navigates to this section they will see if any previous activities of this type exist, and be able to add a new one. BUT this means that the child record is a child via this relationship, not using "regarding", so use a script on the form for the activity so that if Contact is filled in, it is copied to Regarding, and if Lead is filled in then that is copied. If neither, then use an alert or other means to warn the use that something is wrong (see comment earlier). If you want Regarding to be read-only but filled in by script, you will need to make sure to use the force the value to be saved:
Xrm.Page.getAttribute("regardingobjectid").setSubmitMode("always");
You must have the lookups for Contact and Lead on the form to be able to use them in your scripts, but you can make them not "visible by default" so they are there but not seen by the user (and taking up no space).

crm 2011 switch between multiple forms within single entity

We currently design our solutions using a single form per entity. We have a current set of requirements where the 10 or so entities are similar in terms of functionality and data collection. Ideally we would like to have entity with 10 or so forms and dependent on a lookup value display the correct form on the click of a custom button.
I have previously worked with a supplier who implemented something like this displaying the correct form using the GUID (using the formid querystring parameter) on the load event using JavaScript. Although this worked 95% of the time, depending on the client machine it occassionally did not load the correct form due to timing issues i.e. the code had not properly executed by the time the form loaded.
Is there a best practice for using this kind of technique?
I guess my other options are
1) multiple entities
2) one form with tabs/sections that i show/hide on the form load
I am leaning towards implementing option 2)
Richard
The multiple forms inside of CRM 2011 is only for different roles. It is not designed to handle switching between forms based on entity attributes.
Granted what you are trying to do is possible, but you will encounter
issues and will need JavaScript to switch the user to the right form
type. You'll also cause the user to load the form twice each time (kind of ugly)
Another option is to use JavaScript to show/hide the proper elements
on the form (similar to 4.0)
Or you can just use multiple entities with a common JS file for any
kind of logic.
depending upon any field value you can switch the forms through JavaScript.
In JavaScript redirect page to url:
[serverurl]/main.aspx?etn=[entityname]&extraqs=etc%3d[entitytypecode]%26formid%3d[formguid]%26id%3d%257b[recordguid]%257d&pagetype=entityrecord
Where
entityname = entity name (e.g. incident),
entitytypecode=entity type code (e.g for incident it is 112),
formguid=guid of the form to which you want to redirect,
recordguid = guid of the record. If you skip id parameter, form will open in create mode.

SharePoint 2010 - Customizing the rendering and behavior of a List field

In my SharePoint List, I have an "Employee" column that is a User type field. I would like to add some custom Business Logic to the processing of this field.
Currently, when the user adds a row, I check to see if the user is an Employee or a Manager and then change the behavior on this column accordingly. I do this by statically rendering the field in my custom "ListForm Rendering Template", just before my custom ListFieldIterator. I simply use a standard SharePoint FormField (and FormLabel) control. In the markup of the FormField control, I specify the FieldName (Employee) and an event handler for the Load event. In this Load event, I will check to see if the current user is an Employee or Manager (using two different SharePoint groups). If the user is an Employee I set the value of the field to the current user (this part works perfectly). I also want to change the field so it can't be modified. I thought I might be able to just change the ControlMode on the field (in the code of the OnLoad Event Handler) to Display, but for some reason this has no effect. The field still renders with the full, people picker editor. Am I not changing the fields control mode soon enough? Or is this simply not the correct approach? The other logic I want to put in is if the user is a Manager, I would like to allow that user to select the person from a list (SharePoint group) of Employees. It may be easier to just use the people picker and limit the selectable users to that group. (I think I can do this with the SelectionGroup property.) Although, it would be better if I could just provide a dropdownlist of users, which I could possibly do with a hidden dropdownlist that I would show and event handlers that I could use (handle event selectedindexchanged) to pull the value selected and populate the (now hidden) Employee (user) field. Does this approach make sense? Assuming all that will work, the real difficulty I am having is with changing the ControlMode (rendering) on the field (when the user is an employee) to a label or some kind of read only control, which is how that field renders when viewing the row, which is why I think if I can just trick the control into thinking it is in Display mode then it should work perfectly!
I am still learning SharePoint, but I am very proficient in ASP .Net. This is why I would like to keep my customizations in this Custom Rendering Template, using code behind and leverage my existing skill set as much as properly.
Any thoughts, opinions or advice? Does anyone know why I can't get the column to switch the "Control Mode"?
I do not think that I fully understand your scenario. Some code samples could help.
But anyway it sounds like you want some heavy customizations of the user field. In that case you might want to have a look at creating a custom field with all its advantages and disadvantages. Have a look at MSDN: http://msdn.microsoft.com/en-us/library/gg132914.aspx
Another option might be - in case you do not want to re-use this column in many list definitions - that you can get away with your custom rendering template and create a custom create/edit form where you implement the specific edit behaviour for the field (plain ASP.NET with some SharePoint controls). Here is a nice walk-through on how to grab a custom edit form from SharePoint designer: http://community.bamboosolutions.com/blogs/sharepoint-2010/archive/2011/05/12/sharepoint-2010-cookbook-how-to-create-a-customized-list-edit-form-for-development-in-visual-studio-2010.aspx
I hope this helps. Kr., Bernd.

Using the search module to display entries based on custom fields

I have a profile weblog that contains all our users details (fields seperate from the membership).
These users can submit application forms with the use of a SAEF (stand alone entry form), which will be stored in an applications weblog. Inside this applications weblog, I have a relationship field which assigns a profile to an application.
Inside this application, radio buttons are contained to allow an admin to change the status of that application (an example, a judge views an application for Joe Bloggs and sets this application to “winner”).
What I essentially need to do is filter out all the profiles that have not been set to a number of status’. So if I apply for an application and the judge is yet to view this application, my profile should not appear in the search results. My idea of this is that I would somehow have to intertwine search results with a reverse related entry tag, and as my knowledge of the search module is limited I am at a complete loss if this is even possible.
As you can see, not only do I need to search by custom field, but the profiles that will be displayed should be determined on custom fields contained in the application entry.
I would suggest using the "status" option instead of the radio custom field.
Why? Because you can accomplish the same thing you want to do with the radio field and you can set what entries you want to return in your search results.
For example, you have a status group called: "Application", which is assigned to the that weblog/channel
Within the status group, you will have three options: Pending (waiting to be looked at), Loser (judge sets it to this because it is not a winner, or just as pending), Winner (judge considers that application a winner).
Then in the search tag, you would set what statuses it will return in the search results
so if you want to only return applications/profiles that were marked winner, you would set the status="status_id" (this will be the id of "Winner" status)

Resources