javascript - Concatenate two fields in one in CRM 2011 -
in form have date field gets current date in mm/dd/yyyy
format , field auto-generates number.
i want populate field in following format:
yyyy-mm-dd-autogenreate number
.
where year , month , date current dates of form.
how do this? , not @ coding if achieved through java script please specific possible.
assuming field doesn't have populated when load new entity, add onsave event form:
var datefieldvalue= xrm.page.getattribute('datefieldname').getvalue();
var autonum = xrm.page.getattribute('autonumfieldname').getvalue();
/* date formatting guido preite's answer https://community.dynamics.com/crm/f/117/p/109891/218598.aspx#218598 */ // create yyyy-mm-dd string var year = datefieldvalue.getfullyear()+""; var month = (datefieldvalue.getmonth()+1)+""; var day = datefieldvalue.getdate()+""; var dateformat = year + "-" + month + "-" + day; xrm.page.getattribute('otherfield').setvalue(dateformat + "-" + autonum);
note haven't tested might have error in it, should started.
you'll have note populated when entity created / updated on form. backend processes create entity need create same logic.
you use plugin perform same thing if wanted guarantee no matter how entity gets created, has value populated.
Comments
Post a Comment