angular 4 custom form validator - spring-rest

We have a requirement to change attributes of form fields like "required", "hidden", "maxLength" based on selection of one or more fields on the form.
For eg: Based on country selected from a dropdown, the city,state,address1, address2, address3 attributes should change. State may be mandatory for US but not India.
Currently we are using a server side technology JSF2 to implement the view. Spring REST is used as backend. All these country based rules are currently stored in a database table. On application start up these are loaded in memory and derived based on country selection in the view.
In case we need to switch the view to angular 4, please advice if we can reuse this existing rules configuration table to dynamically update the attributes of form fields based on country selection?
Based on checking, angular 4 reactive forms seems to what we can use. It has FormValidators but not sure if these can be dynamically derived/changed based on country based rules derived from backend REST service (in JSON) when country is changed.
Any pointers would be highly appreciated
Thanks and Regards,
Jacob

Related

Create a dropdown menu specific for company in AX

I would like to create a dropdown in AX form so that only the user from specific company see this field as a dropdown and other company see it as string field that user have to manually key in. I only manage to create the dropdown list based on table menu, but have no idea how to limit to specific company.
This create a problem since not all company wants dropdown and If the user key in none registered number, the system will return “ the value xxx in the field yyy is not found in the relating table zzz
How can I set the condition so that only selected company see this field as dropdown and the other company see this as string? And also where to locate the condition?
You may need to set the form control property AutoDeclaration=Yes and then dynamically change the FormStringControl.LookupButton (see here) based on the current company (curext()).
You must also decide if you have a relation on your table, whether or not you want it to be enforced (Validate=[Yes/No]). If you are allowing a free-text field input, I would imagine you would want No, but you could perform validation in the validateField or validateWrite method.
Depending on your situation, you may want to create a custom lookup with a condition.
See how to create custom lookups here - https://learn.microsoft.com/en-us/dynamicsax-2012/developer/how-to-add-a-lookup-form-to-a-control
You'll have to experiment a little, but this information should point you the right direction.
You could add two fields to your form, on with the lookup and one without. You could then use the security setup to control which users have access to which field. Note that this may not work if you have users that work in both companies that use the field with lookup and companies that use the field without lookup.

Drupal 8 Views Question Involving Entity Reference

Trying to figure out views relationships and filters.
I'm trying to make a view that has the title of the page match the entity reference of the same page and make it reactive so I only need one. EX.) Page about animals, which there are nodes referencing the animal page as an entity reference.
Firstly, you have to take one unique field which can identify whether particular node is for animals or etc.
After that, In your views you need to select that field name in contextual filter and select option as you can see in screenshot and then save it.

How can i Validate Form Field in ASP.NET MVC3?

Suppose I have a model named 'company' holding some properties like
Name
Address
fax
And My View (of IEnumarable type (MVC# RAZOR)) has two forms one(form submitting data to different actions) to display list all the available company(existing). And another(form) i used to create new client with Name TextBox Like
#Html.TextBox("name","")
Here i want to add validation to that particular field. Suggest me the possible easiest way?? What i tried is http://www.codeproject.com/Articles/39016/Form-validation-with-ASP-NET-MVC(But it doesn't works)
my view has two forms
Therefore you need two view models because I suppose that the validation rules are different for those 2 forms. So you will have a SearchCompanyViewModel where the Name field will not be required and a NewCompanyViewModel where the Name field will be required.

CRM 2011 - Using contact data on Case form

I've installed CRM 2011 to see if I can tailor it to our business. We do repairs, I want to be able to book in a contact (client) and then a case and have the clients number and address print on the case form. All I can find are fields relevant to the case and not client, any idea on how I can select them?
To get fields from the contact onto the case form you could -
Create redundant fields on the case form for the fields that you want to port over from the contact, and then edit the mappings of the relationship from Contact to Case to map those fields to the case.
Create a web application that loads contact data and then add it to an iframe on the case form. Make it so that the web application accepts the case id in the query string of the URL so that it can look up the related contact and load its details within the web app.
Add JScript (or HTML resource in 2011) to the case form to load the contact values on the fly. You will have to use SOAP XML (or REST endpoints in 2011) messages to pull the data from the CRM service and then can inject it into the CRM case form's DOM.
Option 1 is the quickest solution but will not be realtime (only comes over when the case is first created and must be related to the contact on creation. Option 1 also adds some database redundancy.
Option 2 is the most supported realtime solution, but also requires the most work.
Option 3 is easier than option 2, but any DOM injection will likely not be supported for future releases.
EDIT
To use the mapping option, go to Settings > Customization > "Customize the System". Expand the Case item in the left hand navigation. Then click on N:1 relationships and open the relationship "incident_customer_contacts". This relationship connects the contact to its cases.
On the relationship window click on "Mappings" in the left hand navigation. This controls what fields are mapped from the case when it is created.
Click new and select the contact field from the left that you want to map to the case on the right. Repeat this for each field that you want mapped. Note that the fields need to be the same types, and if they are option sets, they will have to have the same underlying integer values for each of their options.
Now when you create a new case from a contact (or set the contact during the create), the fields should map onto the case.
Seeing as how Craig mentioned he's using CRM 2011, I felt I'd clarify that for Option 3 of Cole's suggestion, you can also use SOAP Xml against the Organization Service, or just use the REST endpoint and both will be supported. So long as you utilize CRM's Xrm.Page object to display the data on the form and don't do any other DOM manipulation, you should be fully supported.
Another Option, "Option 2b" we'll call it would be to add fields to the form for the data you want to be loaded, then add a plugin registered to the Retrieve of the case entity that would populate those fields on the fly for you. No redundancy other than the fields on the form at that point.
I would personally recommend Option 2b if possible because there will not be any lag in loading the data onto the form, and it provides for minimal data redundancy, minimal service calls, and the least amount of additional customizations.
My option is a lot easy one. All we are doing is using Dialog to create cases and in the dialog fields you can get contact detail dynamically. At the end of the form when you create new case, use this dynamic values to submit in Case form.
We get times when customer tell us that the phone number is changed since last time and this method gives you option to change customer's details on the fly and submit both in Contact Entity and Case entity at the same time.

MVC 3 validate dynamic form fields. ASP.NET

I'm working on a very dynamic site build at the moment. What I'm trying to do is creating something like a survey that can be created dynamically from a control panel.
In the control panel you add input fields (these are saved in a database), what the user then see is a form that I generate from the database. So if I add 3 input fields to the database the survey will contain 3 fields. If I add 20 fields the survey will have 20 fields.
Now my problem is that I want to validate these fields, and I would like to be able to hook me in with the standard validation flow. I can't create a Model with validation rules since the number of fields and their names are dynamic the only thing I know is what kind of data that is expected in every field (this rule is found in the database).
In an ordinary case I would get the automatic highlighted fields that are not valid and so on thanks to the built in validation flow with ValidationResult and so on.
So the question now is can I somehow simulate parts of the validation and then hook me back in with the validation result, and if not valid, the form prints the error messages and fill the fields with the data that was given?
Regards
Tobias
What I would do is create some kind of expando model, my own ModelMetadataProvider and might also need my own ModelValidator for that model.
Then, you can easily create validation using the Html.EditorFor and other Html helpers, as they use the metadata to create validation.
BTW, you might also need to create a model binder :)
meta data:
http://mgolchin.net/posts/21/dive-deep-into-mvc-modelmetadata-and-modelmetadataprovider
http://weblogs.asp.net/seanmcalinden/archive/2010/06/11/custom-asp-net-mvc-2-modelmetadataprovider-for-using-custom-view-model-attributes.aspx
http://bradwilson.typepad.com/blog/2010/01/why-you-dont-need-modelmetadataattributes.html
validator:
http://dotnetslackers.com/articles/aspnet/Customizing-ASP-NET-MVC-2-Metadata-and-Validation.aspx#s2-validation
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-the-New-Dependency-Injection-Support-Part2.aspx#s10-new-support-for-validator-provider
model binder:
http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx
This might bo overkill... But these are the extensibility points that you can use.

Resources