How to limit the amount of User Points users get? - drupal-7

I've a content type 'Content' with the field 'Value' (an integer) and a flag called 'Publish Content and grant points to user'. Every time a Content is flagged with this flag, I'd like to grant the Content's author some User Points, equal to the value in the 'Value' field, but with a maximum of 5.
I've got a question about the 'maximum 5' condition. I made 2 seperate rules with an extra condition 'Data comparison': one with [flagged-node:field-value is lower than 6] and another with [flagged-node:field-value is greater than 5]. (Note that I can choose "field-value" here!) Isn't it possible to do this in just 1 single rule?
Note: I also have a problem with the 'Value' field. See: Grant user User Points equal to value of certain field.

I found a solution for my question; maybe it can help others too. I actually created a 'correction' Rule that's activated after a user was awarded userpoints and a 'Content' node was flagged with 'Publish Content and grant points to user'. This is how I set up the Rule:
EVENT
User was awarded userpoints
A node has been flagged, under 'Publish Content and grant points to user'
Then, I checked whether the amount of points is higher than 5.
CONDITIONS
Data comparison: [userpoints-transaction:points] is greater than 5
Finally, I calculated the difference between the added userpoints and 5 and substracted this value from the user's userpoints.
ACTIONS
Calculate a value: [userpoints-transaction:points] "-" 5 (variable name: difference)
Calculate a value: [difference] "*" -1 (variable name: substract)
Grant points to a user: grant [userpoints-transaction:user] substract points
I had to insert the second calculation, because otherwise, I couldn't substract the 'difference' from the user's userpoints.

Related

What does the dummy value mean?

Input the Employee no and the Basic Salary of the Employees in an organization ending with the dummy value -999 for Employee no and count the number Employees whose Basic Salary >=5000.
As used here, a dummy value is different than a regular value, and used to select an organization. It may signify test data.
In production software, you don't want to assign meaning to a partial value of a field. As this implies that any changes to the value of a field may break your software unexpectedly. Instead create a new dedicated field (boolean is_test_data).

Salesforce number field default value to (highest number in a record) + 1

I'm new to Salesforce and I'm trying to make a field for an account number. It will be a unique number that increases. But I would like its default value to be an increment from the highest number of current records since I'm going to import data and those data have some unused account numbers in between.
For example, I have a data with account numbers: 1, 4, 10, 13, 14 -> then the next one's default value would be 14 + 1 = 15.
What's the simplest solution to this? I tried MAX(Account_Number) + 1, but it's not allowing me to use its own value.
I had this issue once and solved it by setting the field as an auto-increment and then creating and deleting large quantities of records to reach my starting number.
If you are importing and want to retain the previous values, this will not work, unfortunately.
You can use a trigger or flow to populate the account number after a record is created.
For the quick and dirty, make a flow and call it from a process builder. If you have the ability to use sandbox and create a trigger, by all means.
Essentially, you would query the sObject with SORT BY AccountNumber__c DESC LIMIT 1 (or whatever the field is named) and access that highest value and increment it and use that to set the value of the record you are creating.
Makes sense?

How to make a field required in Microsoft Access form based on the criteria of another

Form Name: Inventory_Adjustments
Field One: Qty_Adjusted
Field Two: Approved_By
Hello, I am trying to achieve the following and cannot figure out how.
-User inputs Qty_Adjusted Value less than 3, Approved_By is not required.
-User inputs Qty_Adjusted equal to 3, Approved_By is required with message "seek
level 1 approval".
-User inputs Qty_Adjusted between 3 and 10, Approved_By is required with message
"seek level 2 approval".
-User inputs Qty_Adjusted greater than 10, Approved_By is required with message
"seek level 3 approval".
Basically you are going to put a check on the Qty_Adjusted field in the Before_Update event.
Then you are probably going to have either a nested if, or an if-then-else chain for each condition. Pseuedo code:
If less than three, do nothing
else if equal to 3 then check the value of `Approved_By` is at least 1
else if less than 10 then check the value of `Approved_By` is at least 2
else then check the value of `Approved_By` is at least 3
Display errors/messages in each section as appropriate and then abort the update.
Otherwise, let the update proceed as normal.

Calculate and updated a score according to selected answer

I am new to ODK and XLSForms.
I have several questions and based on the answers, I need to calculate a score.
I have 17 questions, each time a person answer yes, I need to add 2 points into an integer field.
So I have:
type name label appearnce required
select_one yes_no1 q1 //question here //appearance quick //required yes
...
select_one yes_no17 q17 ...
And here is the score field:
type name label
calculate total Total
This is my first assignment in my job, and can't figure how to calculate and change value according to selected answer.
EDIT
I added a calculation expression but can't know how to get the result because it didn't worked:
if ((${q8} = 'yes' orĀ ${q9} ='yes' or ${q11}='yes'), 2, 0)
So if question 8, 9 or 11 are answered as yes, add 2 points to current value, but the field didn't appeared at all. And still need to add if question 10, 12, 13 and 14 are answered with yes to add 1 point for each.
The simple but tedious way to do this is to create a calculation for each question with an if() statement that sets the calculated value to either 2 or 0. The final result can be obtained by adding up the calculated items.
The cool way to do this is to do it all in one XPath expression. Basically you want to create a nodeset that contains all 17 questions, filter these to the ones with value 'yes', count the filtered nodeset and multiply by 2. You can do this in XLSForm, but Im not sure if you can use the ${node} shorthand.
You'd have to put all your question in a group (doesn't need a group label) after which you can do something like:
count(${grp}/*[text() = 'yes']) * 2
or without ${node} shortcut (check the XForm for the correct path):
count(/myform/grp/*[text() = 'yes']) * 2
I'm not sure if the use of text() will pass ODK Validate though. If not there is probably an expression that will pass and does the same. (However, the above syntax would work in Enketo).

I have 4 fields 2 fields are lookup to user, 2 fields are date/text

I have 2 fields
Approveuser (lookup to user object)
Approveuserdate (formula field (or) text field)
when i fill the data on Approveuser, i need to diplay automaticlly on this field (Approveuserdate ) date/time.
Please help me
Thank
Your requirement is not clear. Have you already tried something?
When user is creating / editing some record and he selects a value in 2 user lookup fields, you want to set "current date & time" in some other fields?
Try reading about workflow rules in your help & training.
I'd make a workflow similar to this:
Run: every time record is created or edited
Criteria: "User lookup field 1 - not equal to - (leave blank)"
Field to update: "Date/time field 1".
Formula to update it with: NOW()
Remember to activate the workflow.

Resources