I'm working in gosu(guidewire) and having an annotation for the Date Of Birth(DOB).The expression under that annotation is supposed to return an error if the year of the DOB is less than 1897 or if it is greater than 2001.
I'm new to gosu so can someone please help me with this?
There is no OOTB annotation for DOB Validation.
You have to create custom annotation for achieving the same.
Create New Gosu Class -> Change the kind as Annotation
Related
Can anyone tell me which method to put a Query Range into for a class which is batchable?
I have a sample batch class, which runs fine. It retrieves all the records in the Sales Table. I know that I need to add a QueryBuildRange object somewhere, then set the value of the range to a particular value (e.g. Sales ID = 00123456), but I'm not sure what method to put it in (main? Run? QueryRun? InitQuery?)
Thanks for your help!
It depends on what you're wanting to do, but in AX 2009 for batch, you can look at InventCountCreate_Base for an example of how Microsoft does it.
Specifically these two methods:
\Classes\InventCountCreate_Base\new
\Classes\InventCountCreate_Base\initQueryRun
Microsoft does it several different ways. You can see an alternative method in WMSShipmentReservationBatch in these two methods:
\Classes\WMSShipmentReservationBatch\main
\Classes\WMSShipmentReservationBatch\buildQueryRun
I need to create an EDT that will use DimnesionValuesLookup.
So I've made an EDT with reference to my View that has DisplayValues for my specific dimension type, also I set formHelp property as DimnesionValuesLookup. And when I'm trying to open lookup on query search criteria I get an error:
Form should be called with parameters
I looked into the Init() method of DimnesionValuesLookup and found out that I need to pass DimensionAttribute as a record.
How can I do this?
Your comment did not answer my question, but I'm assuming you have a way to identify the name of the attribute for which you want to lookup values. Using the name you can select the DimensionAttribute record that you need to call the lookup form by using the findByName method of table DimensionAttribute. After that you can call the lookup form. Standard AX does something very similar in form DimensionValueInterval, take a look at the lookup method there.
I'm building content type using dexterity. We've date of birth field and by default year range is +- 10 year from current year.
Date field need to be modify and year should start from 1950. I did bit goggling and couldn't find right information I'm after.
Below is my DOB field definition.
dob = schema.Date(
title=_(u"Date of Birth"),
)
Any advise or reference would be great.
Thanks in advance.
Use the collective.z3cform.datetimewidget (https://github.com/collective/collective.z3cform.datetimewidget)
for your field.
This widget has a yearRange attribute.
By default it gets the range defined in site_properties: calendar_starting_year and calendar_future_years_available
Check the documentation if you don't know how to setup the widget
BTW since Version 1.2.4, You can set the min/max value on the field.
I have a dexterity content type (container) where I have two custom fields for a contract start date and end date.
When creating the type I’d like the end date to be used also for the Plone “expiration date”.
How do I copy the Date over to the Expiration Date field?
I think you have 2 approaches to solve this: the first is to use the standard expires field directly instead of your custom end date field; you could have an issue if you want to override the label/description of it, as you will have no way (AFAIK) to change them only for your domain.
the second one could be to override the standard expires field and make its getter method return the value of your custom end date field.
check the following documentation:
Plone and Dexterity: Working with computed fields
Plone Developer Documentation: Behaviors
Medatada definitions inside plone.app.dexterity
I am using Entity Framework with asp.net mvc, but I don't think mvc plays a big role here.
I have an object Customer, and a lookup table (there are several, and they all behave the same way; so for simplicity I'll pick Territory). Both Customer and Territory have LastUpdated field (Datetime that is set manually in the code).
If I hardcode Territory, and get only Customer data from the View, I don't have any problems:
public ActionResult CreateCustomer([Bind(Exclude = "CustId")] Customer cm) {
cm.Territory = (from t in repo.Territory where t.ID == 2 select t).First();
repo.AddToCustomer(cm);
repo.SaveChanges();
}
As I said, no problems. However, if I use a dropdown in the view with the matching id (Territory.ID) - there is a problem. I have the following line in controller:
ViewData["territory"] = new SelectList(repo.Territory, "ID", "Name", 1);
and corresponding line in the View:
Territory: <%= Html.DropDownList("Territory.ID", (IEnumerable<SelectListItem>)ViewData["territory"])%>
I get good news and bad news: the good news is that I get the territory ID nicely assigned to the appropriate member of Customer object. The bad news is that Territory.LastUpdated value is set to 1/01/0001. Obviously, I don't care about this value - but it looks like EF cares. When I call SaveChanges I am getting the following error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
Looks like EF is trying to retrieve the value from the database, and then compare it with EF value... or maybe something else - but the bottom line is I can't figure out how to prevent it from trying to be so smart.
For now, I name DropDown ID to be something different ("terID" instead of "Territory.ID"), and using FormCollection:
int terID = Int32.Parse(formData["terID"]);
cm.Territory = (from d in repo.Territory
where d.ID == terID select d).First();
This works (which makes me comfortable with my analysis) but this cannot be the best way.
I also can't believe that nobody bumped into such problem - but I couldn't find anything relevant... The best I could find is link text but it's more of a hint without much details
I tried to cut out all unrelated stuff from the code - so if there are some typos, they are in the post; not necessarily in the code itself!
Thanks
Territory.LastUpdated is being set to the default value, as EF saves the whole row / what has changed you get an exception.
The easy way to fix this is to set it to DateTime.Now before saving.
I'm assuming you are using EF 1.0 which is not good at direct foreign key maping.
Territory posted from view to action is not bound to Datacontext, hence when you save your customer object - EF saves attached Territory Object as well.
You have to get Territory object from db first and then assign it to customer.
And Your solution is perfectly fine, cos there is no other for EF 1.0 )-: