Angular-formly clean error - validation

I have two fields whose validation logic depends on each other. Sometimes field 1 raises a validation error, but modifying the value of field 2 should make the value in field 1 as a valid one. Any idea if there's a way to do that in Angular-formly?
For example, let's say I have a field called dateOne and another one is called dateTwo. dateTwo should come after dateOne. If I enter dateOne as 2016-08-29 and set dateTwo to 2016-08-28, my validator for dateTwo returns an error, saying dateTwo should come after dateOne. If I set dateTwo to 2016-08-30, the error will go away and my from becomes valid, which works fine. However, if user changes dateOne to 2016-08-20, my form is technically valid, but it still remains invalid as I need a way to remove the validation error from dateTwo and make the form valid.

I don't know which calendar you are using, if you are using bootstrap then it is very simple.
in dateOne textbox:
max-date="model.dateTow"
and in date two:
min-date= "model.dateOne"
Once you select the start date, end date calendar will disable all the dates before selected date,
Once you select the end date, start date calendar will disable all the dates after end date.
See the complete article

Related

JavaScript: how to trigger update form after setting input

I am writing a simple App Inventor program to populate a Covid-19 school health check page. I am stuck on selecting a school. Normally you type in a school name, the page finds string matches and you select from the list of string matched school. I am able to simply set the field manually but the rest of the form doesn't update. I know I must trigger an update but I cannot make head or tails of how this page works.
image of school selection
typing in part of school name
From the Chrome console I can do the following:
x = document.getElementsByClassName("k-textbox")
x[1].value = "Horace"
From the picture you can see the text was updated to "Horace" but the results have not updated. What should I do to force an update so the results list shows proper matches? Also, how do I query the matching results so I can confirm that my input was explicit enough to return a single match? FYI, this form entry page will be hidden to the user.
You can get the kendoDropDownList, call the read method from it's dataSource, and pass the locationName value of what you want. This won't set the text in the textbox, but it will filter your list down like you want.
To test, click on the input, open your console, and run the following:
$('#Location').data('kendoDropDownList').dataSource.read({ locationName: 'horace' })

How to save a record with validation rule in place

I currently have a validation rule that prevents user from making changes to a record when its status is completed. Users are only allowed to make changes if the status is either draft or registered.
AND(
TEXT(Current_Status__c) <> "Draft",
TEXT(Current_Status__c) <> "Registered"
)
There is a new requirement to allow user to update only a specific picklist value field even if the record status is completed. If i remove the validation rule, user will be able to change any fields on the page layout which won't work.
Object setting for the profile is read, create, edit. This object is a child object to Opportunity, OWD is controlled by parent.
Any recommendation on how to solve this issue ?
Thanks in advance.
We can rewrite your rule as ISPICKVAL(Current_Status__c, 'Completed') for example, looks bit cleaner. Your call though, you can keep as is.
So what you'd need is something like ISPICKVAL(Current_Status__c, 'Completed') && !ISCHANGED(Some_Picklist__c). It should let the edit through if you're modifying that picklist.
The problem is it won't check if that's the only change. Usercan cheat, modify 10 fields and they'll "piggyback" and save OK as long as one of them is that picklist.
It's pain to write validation like ISPICKVAL(Current_Status__c, 'Completed') && !ISCHANGED(Some_Picklist__c) && (ISCHANGED(Field1__c) || ISCHANGED(Field2__c) || ISCHANGED(Field3__c)). You'd have to add all editable fields to it, change it every time you make new one. And eventually you'll hit length limits.
I know 3 options for this if it's a concern for you:
Ask a developer to rewrite your logic to Apex trigger, it could then go dynamic through all fields (using "describe" calls to learn field names or stuff like getPopulatedFieldsAsMap.
Another trick is to allow editing completed records only through a quick action, not normal edit page. In that action you could set some hidden checkbox in the field prepopulating step and your validation would let the save through only if that checkbox is set. But then you need to deactivate it somehow anyway or the bypass will get permamently enabled.
If you don't have too many record types on the object a common trick is to change the record type on completion (workflow, process builder etc). And have another page layout with all fields locked down except that special picklist. It works good enough for UI changes but won't protect if you have code and integrations writing to the object too.

Watson Assistant Slots: how to allow the user to re-enter data using non-dictionary entities?

I want to capture the following input from the user and am using these entities:
First and last names: use sys-person (I extract first and last names later using a cloud action).
Email address: use pattern entity, name #contactEmail and value "email" pattern \b[A-Za-z0-9._%+-]+#([A-Za-z0-9-]+.)+[A-Za-z]{2,}\b
Mobile Number: use pattern entity, name #contactPhone and value "mobileNumber" pattern ^[1-9][0-9]{7}[0-9]+$
Slots
I created a node with slots:
The setup is as follows:
Check for:
Check for: #sys-person.literal Save it as $person If not present: Type your name
Check for: #contactEmail.literal Save it as $email If not present: Type your email
Check for: #contactPhone.literal Save it as $contactPhone If not present: Type your mobile.
This all works perfectly and I get the name, email address and Phone number.
The Challenge
But I want the user to be able to confirm that the details are correct.
So I have an intent called #response_yes which is activated by things like "yes", "yep", etc.
And I have a fourth slot that checks for #response_yes.
Check for #response_yes, store the value in $confirmed, if not present ask "Got $person, $contactEmail, $contactPhone is that correct?"
If #response_yes is not found, then it displays the values already typed and asks if they are correct and waits for user input.
After the user has responded, then if the #reponse_yes intent is still not found, then:
Respond with, "Let's start again".
Also, we need to clear the values already typed:
Here's where it goes wrong
When I try the chatbot, the node collects the input correctly and displays the values correctly and asks if they are correct. I type "no", the #response_no intent is correctly divined and I would expect the prompt for the first slot to show again, but it doesn't.
No matter what I type at that point, the assistant bypasses the top three slots and drops to the fourth one again. It's as if I need to clear the entities, not the variables.
What am I doing wrong? How do I make the top slot work again?!
Aaaaargh.
For anyone who's interested, I simply didn't reset the values to null.
I guess I assumed that leaving the value blank was the same as null. Not so. Once I did this, the system worked perfectly:

Either type validation in Codeigniter?

I have two controls one dropdown (cmbCategories) and second one input textbox (txtCategory).
Now, I want to add validation. If Category is not selected from cmbCategories dropdown, it will look for txtCategory textbox. If both are not present then it should be given an error just say 'Either you have to select Category from dropdown list or enter into Category textbox'.
I have used following type validation rules but it gives unexpected results.
$this->form_validation->set_rules('cmbCategories','Category','required|is_natural|xss_clean');
$this->form_validation->set_rules('txtCategory','Category','required|min_length[5]|xss_clean');
How I achieve the functionality that I am looking for?
CI's validation methods can only be called on a single input so I don't think that you will be able to use them alone for what you are trying to do. I would just check the post vars that are submitted and make sure that they both aren't empty.
if ($this->input->post('cmbCategories') == 0 && $this->input->post('txtCategory') == '')
{
// set error message and stop processing
}

Getting a blank data report vb6

I am new to vb6. I am working to create the invoice generation application. I am using data report to show the generated invoice.
The step by step working of process is:
Entering the data in to Invoice and ItemsInvoice tables.
Then getting the maxId using (Adodc) from the data base to show the last generated Invoice.
Then passing the max Id as parameter to the data report which is showing the invoice according to the invoice id.
It is working fine when I first time generate invoice. Now for 2nd invoice without closing application I am getting a blank data report. For data report I am using dataenvironment.
I am guessing the reason the data report is blank is because there was no record for that Id, but actually the record is inserting in the database.
What is going wrong?
I'm not sure how your data set is getting configured, but it sounds like you have a single record in the data and aren't reloading it properly. If your report is manually moving through the recordset and only showing info based on the ID parameter you are passing it and then using the same recordset for the second report, you probably just need to MoveFirst on the recordset to put it back at the beginning.
Load the data environment and refresh the data report.
I am also generating report in the similar fashion. I faced this problem. Here's the solution
Load DataEnvironment1
With DataEnvironment1
'Command1 is the command added to data environment where you fire query or
'set it to point to a table
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1 maxid 'parameter you pass to the recordset
End With
DataReport1.Refresh
DataReport1.Show
Thats it!
You are done. I m sure it will work. Do tell me if it doesn't.
I don't know if the answer will still bother you, but if someone else have the same problem here is a example of how the problem works:
Imagine that there is a gate and a guard looking who is entering, when the first person (the first invoice) comes, the guard registers him, opens the gate (This is the event "Load DataEnvironmet") and then lets the guy pass. The guard believes that no one else would come and lets the door open (the instruction believes that the DataEnvironment ends and the value EOF becomes True), but when the second guy comes (the second invoice) the guard can't ask him who is (has, again, the value and lets it pass without registering him (this is the reason why the second invoice, and subsequent in while invoice would come blank). The solution is to close the gate ("Unload DataEnvironment") after a guy passes (After showing the data report).
The solution is the code given from Sangita above, but just before ending the sub you need to unload the DataEnvironment you were working on.
For me, it works. Sorry if the answer is not what you were looking for (and also if someone else can't understand what I'm writing, my English isn't very good). Just in case I will write the code with the solution
Load DataEnvironment1
With DataEnvironment1
If .rsCommand1.State <> 0 Then
.rsCommand1.Close
End If
.Command1 Value(ID)
End With
DataReport1.Refresh
DataReport1.Show
Unload DataEnvironment1
Try a refresh method like data1.recordset.requery or
Data1.refresh. This should work if you use data controls.

Resources