12.07.2015 Views

Database.com Metadata API Developer's Guide - Salesforce.com

Database.com Metadata API Developer's Guide - Salesforce.com

Database.com Metadata API Developer's Guide - Salesforce.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Metadata</strong> TypesProfile}// Employees and managers have the same app visibility...ProfileApplicationVisibility appVisibility =new ProfileApplicationVisibility();appVisibility.setApplication("ExpenseForce");appVisibility.setVisible(true);Profile employee = new Profile();employee.setFullName("Employee");employee.setApplicationVisibilities(new ProfileApplicationVisibility[] {appVisibility});AsyncResult[] arsProfileEmp =metadataConnection.create(new <strong>Metadata</strong>[] {employee});Profile manager = new Profile();manager.setFullName("Manager");manager.setApplicationVisibilities(new ProfileApplicationVisibility[] {appVisibility});AsyncResult[] arsProfileMgr =metadataConnection.create(new <strong>Metadata</strong>[] {manager});// But employees and managers have different access// to the state of the expense sheetRecordType edit = new RecordType();edit.setFullName("ExpenseReport__c.Edit");RecordTypePicklistValue editStatuses =new RecordTypePicklistValue();editStatuses.setPicklist("ExpenseStatus__c");editStatuses.setValues(new PicklistValue[]{unsubmitted, submitted});edit.setPicklistValues(new RecordTypePicklistValue[]{editStatuses});AsyncResult[] arsRecTypeEdit =metadataConnection.create(new <strong>Metadata</strong>[] {edit});RecordType approve = new RecordType();approve.setFullName("ExpenseReport__c.Approve");RecordTypePicklistValue approveStatuses =new RecordTypePicklistValue();approveStatuses.setPicklist("ExpenseStatus__c");approveStatuses.setValues(new PicklistValue[]{approved, rejected});approve.setPicklistValues(new RecordTypePicklistValue[]{approveStatuses});AsyncResult[] arsRecTypeApp =metadataConnection.create(new <strong>Metadata</strong>[] {approve});} catch (ConnectionException ce) {ce.printStackTrace();}UsageWhen you use the retrieve() call to get information about profiles in your organization, the returned .profile files onlyinclude security settings for the other metadata types referenced in the retrieve request (with the exception of user permissions,IP address ranges, and login hours, which are always retrieved). For example, the package.xml file below contains a typeselement that matches all custom objects, so the returned profiles contain object and field permissions for all custom objects inyour organization, but do not include permissions for standard objects, such as Account, and standard fields.*CustomObject*136

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!