Hi Guys,
I am preparing an application using webservices, where I want to know how to identify the lookup fields for eg: No: in sales line is (No = item (where Type = item) or No = GL Acc(where Type = GL Account).....).
I came through one of the post that reading page and table data in object metadata table will give the info. can you guide me on how to use this table?
0
Comments
Inside the function
set filter on object type and No. for that table
calcfields blob field that has the metadata. stream it into the bigText.
In you C sharp code you have have the BigText string and you can then part and get what you want.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I have created a CU as:
OBJECT Codeunit 60000 Read MetaData
{
OBJECT-PROPERTIES
{
Date=05/04/10;
Time=[ 3:22:34 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
END;
}
CODE
{
PROCEDURE ReadObjectMetaData@1000000000(VAR BigtxtVar@1000000000 : BigText;"Object Type"@1000000004 : 'TableData,Table,Form,Report,Dataport,Codeunit,XMLport,MenuSuite,Page,,System,FieldNumber';"Object No"@1000000005 : Integer);
VAR
ObjMetaData@1000000003 : Record 2000000071;
bstr@1000000002 : BigText;
isstream@1000000001 : InStream;
BEGIN
ObjMetaData.RESET;
ObjMetaData.SETFILTER("Object Type",'%1',"Object Type");
ObjMetaData.SETRANGE("Object ID","Object No");
IF ObjMetaData.FINDFIRST THEN BEGIN
ObjMetaData.CALCFIELDS(Metadata);
ObjMetaData.Metadata.CREATEINSTREAM(isstream);
BigtxtVar.READ(isstream);
END;
END;
BEGIN
END.
}
}
In the C# code I have added as follows
ObjMeta md = new ObjMeta();
md.Credentials = new NetworkCredential("Administrator", "123", "WORKGROUP");
md.Url = ConfigurationManager.AppSettings["ObjMetaData.ObjMeta"];
String input ,output;
input = "Blocked";
output = md.ReadObjectMetaData(ref input,1,18); //- Facing error
But I am not getting how to part for field, I want to know option values for Blocked field in Customer table and for contiditional lookups
public static List<String> getOptionFieldRestrictionsFromSchema (XmlSchemaSimpleType optionFieldType){
// the content of the type should contain a collection of restrictions (facets)
List<String> ret = new ArrayList<String>();
try {
XmlSchemaSimpleTypeRestriction typeRestrictions = (XmlSchemaSimpleTypeRestriction)optionFieldType.getContent();
XmlSchemaObjectCollection facets = typeRestrictions.getFacets();
int numberOfFields = facets.getCount();
for (int i = 0; i < numberOfFields; i++) {
XmlSchemaEnumerationFacet restriction = (XmlSchemaEnumerationFacet)facets.getItem(i);
ret.add((String)restriction.getValue());
}
} catch (Exception e) {
}
return ret;
}
http://www.wmmatthewstreet.com
But I want to know the way to find the coniditions in a lookup field?
Thanks Rashed for the help
Reading the object metadata table is working fine for me but I am not able to read meta data for few tables like T 18, rest everything is working fine, I am running the page and form in RTC its working fine.
Has anyone experienced this kind of behaviour? I am facing the error "There is an error in XML document (4, -285)." for T-18 in my .net application. this started happening after I restored the backup in a new DB.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
after you run this. Open c:\18.xml file make sure it's a valid xml file. If it's not, try to delete the record from Object Metadata an try to recompile the object.
This will recreate the record.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Considering the case of wrong file generated, I am recompiling the object, restarting the server, still the same thing ](*,)
was it a valid xml file??
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
SETRANGE without FIND will not return a record. So the CALCFIELDS results in an empty BLOB...
Change the code to:
My blog
I coppied the code but didn't copy everything.
Thanks for catching that.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
My blog
Are you able to export the Metadata field as an .xml file and open it with Internet Explorer?
If yes, then you might have a problem with serialization and deserialization of the XML stream via webservices. Are you using Visual Studio? Have you refreshed your webservice reference so that the proxy class is recreated?
My blog
I found a strange reason for this, actually in by database I have installed Language packs (french, Germany etc) and I have restored the same backup in another Database(same lang packs are installed in this). Here for the Objects for whch I have modified in my DB I was facing the error and rest other was working fine.
I have again restored the object from CRONUS without other language packs, it is working fine. I did not get why language packs was creating an issue?
Is it possible for you to catch the exception and look into the InnerException property?
My blog
In you .net code save the xml file sent to a file and take a look at it.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Try to remove the language from just one object and see if that solves the problem.
My blog
i have seen this sort of error with the customer table when trying to export fields with captions attached
for example field 10015 Tax Exemption No.
The caption ML is as below, the parse does not like the FRC sections.
ENU=Tax Exemption No.;FRC=N° d'exonération fiscale;ENC=Tax Exemption No.