use Table Value Function in mJoin - .net MVC Project
use Table Value Function in mJoin - .net MVC Project
montoyam
Posts: 568Questions: 136Answers: 5
in DataTables
I have often successfully used a function in a .LeftJoin
.LeftJoin("udf_Lookup_FTEDeptName('" + AsOfCookie + "',1) as udf_Lookup_FTEDeptName", "udf_Lookup_FTEDeptName.ID", "=", "SystemUsers.DepartmentID")
However, I am getting an error when trying to use a function in a .MJoin.
.MJoin(new MJoin("udf_SystemUsers_LineItemDetails('" + AsOfCookie + "') as LineItemDetails")
.Link("LineItemDetails.SystemUserID", "SystemUsers.SystemUserID")
I am getting the error
'udf_SystemUsers_LineItemDetails' is not a recognized built-in function name.
are .MJoin's not able to use a function? unfortunately I need to pass a date so I can not use a View.
Answers
No, I'm afraid they are not at this time. That said, the error suggests it might be trying to execute it. If you add
.Debug(true)
what is the JSON returned from the server please?Allan
I get the following:
Yeah, that second query looks a bit odd.
I got rid of the 'as LineItemDetails' in line 26 above and now get this:
It seems to me the MJoin does not handle the 'as' portion as the .LeftJoin does.
It should return a query like this:
Yes, reformatting it gives us:
I can see why you went for the
as
there! In the PHP versions of these libraries there is atableAlias
option which might resolve this issue. Let me have a think about how this might be resolved. It might be a few weeks before I get a chance to dig deeply into this at the moment though, as support requests are quite high at the moment.Allan
thank you. I created a function to use in place of the primary table (since it is read-only). It won't do exactly what I need, but it will be a band-aid until this gets worked out
Nice workaround - thanks!
Allan
Do you have an estimate as to when the alias in an mJoin may be looked into?
It is planned for Editor 2.1 but that is likely some months away I'm afraid. Probably towards the end of 2021.
Allan
Old thread this sorry! But I thought I'd offer a quick update while I'm going through my backlog. I've been reviewing how the PHP implementation works (I mentioned it above) and actually it wouldn't help at all as it renames the Editor host table, not the table that is Mjoin'ed.
I think the best way to get this working with Editor would be with a function or VIEW, similar to what you have done. I don't have a suitable change for this yet. Apologies for the massive delay.
Allan