gravityform get the "key" instead of "value" of a multiple checkbox submitted form? - gravityforms

I try to explain my problem. Fast question is at the bottom, here I'm just explaining the more detailed I can
I have a gravity form with some questions, 2 of these are multiple choice checkboxes.
I'm assigning a numeric value to each of the answer, for example:
by default the choices are
first choice
second choice
third choice
if I check the "show values" option, by default the value is the same as the key, so basically
"first choice" = "first choice"
and so on.
I want to assign different scores to each choice:
For example:
first choice = 1
second choice = 1
third choice = 2
to be able to sum them up I'll set up an hidden numeric field with calculation enabled and sum the results based on what they checked, using merge tags
Let's suppose the above example is a field with id 25, I would do something like this to get the sum of those numeric values
{:25.1} + {:25.2} + {:25.3}
this is perfect because like this the hidden field will populate accordingly, and I will be able to see the total score on the admin-side... but at the same time I will not be able to see the answers they've chosen, because they will be numbers (corrisponding to the values I assigned before) and since most of them have the same value I'll not be able to know which answers were selected..
So the output on the admin side would be something like:
For example: //this is the name of the question
1
1
2
Long story short: I need to find a way to display on the admin side the chosen answers by their keys, and not by their values.. (while being able to perform a calculation with some scores I assigned) Any suggestion?
Thanks,

Related

Trying to add up selections from a drop down menu to attain a score in excel

Sorry if this question is a little basic, but basically what I have is 4 types of change in column H and I want to get a score (were calling it type value) in Column I. I want it to work for each type of change a person selects, the type value goes up by one. For example in the first row I have there are three selected from the drop down menu (People, Process, Tools) so I would want type value to be 3. Appreciate the help in advance and let me know what enter image description hereyou think

Prompt Page Static Choices

I am trying to create a prompt on my prompt page to let the user select a specific quarter. for example, the user would select "2018 Q1" from a prompt and the report would know that the dates for "2018 Q1" are between 7/1/2018 and 9/30/2018. Is this possible to do? I have been messing with the static choices, but I am not getting very far.
My Cognos knowledge would be classified as general.
There are a couple ways to do that. You didn't indicate whether you want the choices offered the user in the prompt to be dynamic. Dynamic prompts usually provide a better customer experience and require less maintenance. I'll explain how to do dynamic and if you want static, simply hand enter the values into the prompt rather than source them from a query. The rest of the instructions apply.
Dynamic (preferred)
Create a new query
Name the query something that indicates its function, e.g. 'Quarter Prompt'
Within the query create a new data item to contain what you want the prompt to display to the user.
For example, if you wanted the prompt to show "2018 Q1" you might create this string from a Date table like so:
[Year] + ' Q' + [Quarter]
If you generate the tabular data for this query you will get a list of all year/quarter combinations in your date table:
2018 Q1
2018 Q2
2018 Q3
2018 Q4
2017 Q1
...
Constrain the list to only the range of quarters you want to prompt for.
For instance, if you wanted to only show quarters in the current year you'd add this filter:
[Year] = year(current_date)
After adding this filter you will only see the first four rows of the above output returned. Your users will be given four choices to choose from.
Set the value prompt's Query property to the new query and set both the Use Value and Display Value properties to the data item you defined in the prompt query
To apply the prompt choice to your report, you simply add a filter to the relevant report query that takes the input from the user and compares it against the data:
[Year] + ' Q' + [Quarter] = ?quarterPrompt?
Now, this way of doing it has some potential performance inefficiencies. In order to apply the filter each row will have to be examined, converted into the string format and compared. If you need better performance a better way to do the filter is as follows:
[Year] = substring(?quarterPrompt?,1,4) AND [Quarter] = substring(?quarterPrompt?,7,1)
Since we are only transforming the prompt, which contains only one value and not many, the performance is optimized.
Addendum
My intuition was telling me that there might be an even better way. After poking around, I realized that there's an even more efficient way to handle this by eliminating all string parsing. Here's the parts of the procedure to be amended:
You need to add a new data item as the Use Value passed into the report query.
Create a second data item in the prompt query with the following expression:
[Year] * 100 + [Quarter]
For every year and quarter combination you will now have a number that encodes the combination. For instance, for year 2018 and quarter 2 the new data item will return 201802.
Change the prompt properties. Point the Use Value to the newly created data item.
Change the filter in the report query to use the new numerical value
This would look something like the following:
floor(?quarterPrompt?/100) = [Year]
AND mod(?quarterPrompt?,100) = [Quarter]
This numerical-only operation has the potential to have better performance than the substring-based parsing in the original answer, yet has the same effect.

Google Dataprep Sort By Column

I've tried searching for this and had no luck so sorry if it is a duplicate.
I am looking to see if I can sort an Excel sheet by column, in a custom order, using Google Dataprep. I am looking to use the file in BQ afterwards which I why I wish to use Dataprep.
The column name is Stage, and the values are: Closed - Won, Stage Three, Stage Two, Stage One, Prospect, Closed - Lost. Not appearing in that order, but that's the order I want to sort them in.
Thanks for any help!
I managed to get it working even if my solution is a little bit convoluted and consisting of the three following recipe steps (click on Add Step from the Edit Recipe menu for each one):
1) Type derive in the text box and press enter. In the Formula section input the following:
case([stage == 'Closed - Won',0,stage == 'Stage Three',1,stage == 'Stage Two',2,stage == 'Stage One',3,stage == 'Prospect',4,stage == 'Closed - Lost',5])
This will map each of the possible stage to a numerical value so we can use a custom sort in step 2. Define the new column name, for example, orderingPattern. Remember to change stage for the actual column name if those differ.
2) Confirm the step and add a new one. Type window this time and use a dummy formula (I used window = id) and in Order by select the previous column (i.e. orderingPattern). Now the preview should already be ordered as desired:
3) Drop the extra columns as we don't need them anymore (orderingPattern and window)
Final result shows now all the rows sorted according to the custom stage order in step 1:

rowData not working as espected in repeat control

I have : <xp:repeat id="repeatColor" value="#{productcolors}"
var="rowData" indexVar="rownum" >
PROBLEM : rownum goes from 0 to the last correct value, but rowData is always the same
This repeat control is bound to a view "productcolors" , a view with a key on product code.
This view has a first column with the product code , ascending (for the key).
It also has a second and a third column with ascending multiple value fields.(second is framecolor, third is upholstery color)
The idea is that the repeat control goes through the different colors for the selected product, but it only shows the first one and does that the number of times (rownum increases correctly)that there are colors for the selected product.
EDIT :
So I have for example a product called "A" available in framecolors "1" "2" and "3"
When I am using the repeat control rownum changes from 0 to 2 but rowData is always the reference of framecolor "1". I don't know why rowData isn't changing.
When I use rowData.getUniversalID() I am getting 3 times the ID of the document containing the multiple value field with the 1 , 2 and 3 in it, which is I guess normal ? But how can I get a handle to those different values inside it ?
SECOND EDIT
I tried :
var testje:string = rowData.getUniversalID();
var db:NotesDatabase = session.getDatabase(database.getServer(),"product/colors.nsf");
var doc:NotesDocument = db.getDocumentByUNID(testje);
test = doc.getItemValueString("colorUpholstery");
The result is that "test" only holds the first item of the multiple value field "colorUpholstery" .
How is that possible ? I thought I would get the complete value of the "colorUpholstery" field ?
Maybe because I only have reader access(Publicaccess) to the colors.nsf database ?
It would be nice to see a little more code... like what's inside the repeat.. just to get a better feel for it to go along with your description of the Notes View.
rowData should be an XSPViewEntry... basically a NotesViewEntry... I suggest you first do something like rowData.getDocument().getUniversalId() to make sure it is iterating the documents correctly. I'm sure it is.
It sounds like you're trying to do something with a multi-value field.. are you also setting the view to use display multiple values as row entries? or whatever that setting is? That might get dicey if that's turned on. Not sure.
Again I'm not totally following what what the goal is but I would first test to make sure it is actually repeating the expected documents. then it's all about fine tuning.
EDIT: Ok... some thoughts based on your additional info:
I suspect that your problem is the use of the view setting "show multiple values as separate entries". Each is the same document really. So that's likely not helping you here. I'm still a little fuzzy on exactly what you want for the output. Is this from a "view page" of maybe products? a "form page" of a single product?
I ASSUME you want all the colors for a single product? And this is a lookup view right? so you're on your product "document" and now you want to list all the colors?
Assuming so...
Use SSJS and the object model. Do a lookup to find the SINGLE document that has the multi-value color field for your current product. then return to a repeat control something like:
lookupDoc.getItemValue("colorField")
I'm not 100% sure that's the correct syntax. The point is you can send a multi-value field to a repeat control and it will repeat it. Much easier then trying to use view tricks.
If your goal is to have a Repeat of multiple products.. and in side each "row" to show all the available colors then you're looking to have a nested repeat really... The outer repeat (outerData) to iterate over all the main products and inside that another repeat (innerData) for the colors. Inside that repeat code you use the "outerData" to get the multi-value field. Something like:
outerData.getDocument().getItemValue("colorField")
Assuming I'm understanding you correctly these are my suggestions.
I did do an example of nested repeats like this on an early NotesIn9. I believe it was this one: http://notesin9.com/index.php/2010/03/30/notes-in-9-show-14-repeats-repeated/
Maybe that will help.
Second Edit Response:
Based on the code you added you're using "doc.getItemValueString()" By design that will only get you the first value of a multi-value field. This is the same as saying in LotusScript:
doc.colorUpholstery(0)
or the less commonly used
doc.getItemValue("colorUpholstery")(0) ' I might have that wrong. I never really used it
Again if you want to make a list of all the colors I'd use a repeatControl and pass in:
doc.getItemValue("colorUpholstery") then your "rowData" for that repeat will be each value. I've seen others avoid the repeat and doing some javascript explode or implode type thing I believe. using "\N" or something as a separator for a new line. I just use a repeat. Easer for me to understand.
Again I THINK everything you need really is in NotesIn9 episode 14.

Need to display the columns based on input values in cognos report

I have requirement. I need to create a text box prompt in the prompt page. In that prompt user may enter branch number or warehouse number. based on these input value i need to display the branch number and warehouse number in the list report.
Ex: if user enter branch number i need to display only branch number in the list. If user enter warehouse number i need to display warehouse number in the list.
Two optional prompts, each tied to respective data item in query
Macro prompt in each data item of query, putting a dummy value in if the respective parameter is empty
Create list in report with both columns and measure
Two variables, one for each parameter, each tied to conditional rendering on the list column
I wrote up a similar technique on my blog. This would automatically sum the report based on whatever data item had values entered on its prompt. It uses all built-in Cognos functionality. You would need to adapt slightly to ensure the user entered at least one value - could quickly hack with JS.
If the branch numbers and warehouse numbers don't overlap then you can do the following:
Add both the branch number and warehouse number columns to your query
Create a new data item and put the following as the expression:
CASE
WHEN ?whse_branch_no? BETWEEN 0 AND 10 THEN [Branch Number]
ELSE [Warehouse Number]
END
Add the new data item to your report
If you are filtering on the input as well you could use similar logic:
IF (?whse_branch_no? BETWEEN 0 AND 10)
THEN ([Branch Number] = ?whse_branch_no?)
ELSE ([Warehouse Number] = ?whse_branch_no?)
Obviously, you'd use your own parameter, data item names, and numerical range but the concept is the same.
If the numbers do overlap then it's more difficult.
You could add a two-option radio button that allows the user to select the context for the text box input, with Branch Number and Warehouse Number as choices. Then you just adapt the logic presented above to use the value passed in by the radio button to choose the data item you want.

Resources