You need to sign in to do that
Don't have an account?
visualforce_dev
Message Edited by visualforce_dev on 01-11-2009 07:52 PM
creation of validation rule using java
Hi,
i have created a custom object and custom fields using java code and metadata API. I want to create a validation rule for a field in this object. I used the following code
where 'co' is the custom object. But following error is coming
Code:
ValidationRule vr[];
vr = new ValidationRule [1];
ValidationRule vrule = new ValidationRule();
vrule.setFullName(co.getFullName()+".myvalidation__c");
vrule.setErrorConditionFormula("Name='sumi'");
vrule.setErrorMessage("Validationisworking");
vrule.setDescription("Myvalidationruledesc");
vr[0]=vrule;
co.setValidationRules(vr);
try
{
UpdateMetadata updateMetadata = new UpdateMetadata();
co.setNameField(namefield);
updateMetadata.setMetadata(co);
updateMetadata.setCurrentName(objectname.toString());
AsyncResult[] ars1 = msfdc.update(new UpdateMetadata[]{updateMetadata});
if(ars1.length>0)
{
System.out.println("Updated Successfully");
}
}
catch(Exception e)
{
System.out.println("Exception:" +e);
}
where 'co' is the custom object. But following error is coming
Cannot create child objects through metadata create / update. The ValidationRule must named 'obj13__c.myvalidation__c' be created separately
Any help will be grt...
Thanks in advance.
Message Edited by visualforce_dev on 01-11-2009 07:52 PM
its working now, dont give __c while setting name. closing this thread. :smileyvery-happy: