+ Start a Discussion
abhishek_sf@hotmail.comabhishek_sf@hotmail.com 

How to create a profile using metadata api through apex class Options

Hi all

 

    I just want to create the profile using meta data api, but there are some hurdels 

 

I am able to create custom object using metadata api the sample code for that is

 

public static void createObject()
{
MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { customObject });
}

 

In the similar manner i want to create profile using meta data api, if any one has anty idea then please give me the code

Vinita_SFDCVinita_SFDC

Hello Abhishek,

 

Unfortunately it is not possible to create a profile via metadata API, you can only retrieve it content using metadata API. For details please refer the section Profile for better understanding on how to work with profile using metadata API:

 

http://www.salesforce.com/us/developer/docs/api_meta/

Deep067Deep067

Thanks Vinita  for your reply

 

 But is any possible way to create profile using apex.

I also want to know How to add field in object page Layout using Apex metadata api 

 

Write now I am able to create object, field , and many more thing using Apex metadata api

 

 

Thanks in advance

Vinita_SFDCVinita_SFDC

Hello Deep,

 

Yes you are correct, we can create fields, objects but it is not possible to make any DML operation on Profile. I would suggest you to post this idea on idea exchange if you wish to have such functionality in near future relelase on idea exchange portal:

 

https://success.salesforce.com/ideaSearch

 

 

abhishek_sf@hotmail.comabhishek_sf@hotmail.com

Thanks Vinita  For Reply

  

   As Per now I am reserching on this topic, and complete my reserch with in two or three days, If u find any link related to profile then please mail me,

My mail id is abhishek_sf@hotmail.com.

 

Abhishek Tiwari