7

I needed to first create some Record Types for some custom objects using Metadata. After doing those, I was to upsert the records on those custom objects using the RecordTypeId.

I noticed one thing that one needs to set the visibility of the Record Types from Profile otherwise the Error comes - something like Invalide RecordTypeId for the User.

So, I have the flow of my application set from Java as

First create the Record Types, thereafter fetch the RecordTypeID and then upsert the records on the custom object I need to target.

So, I need to update the Profile using Metadata API itself to set the visibility of Record Types as:

ProfileRecordTypeVisibility[] prtv = new ProfileRecordTypeVisibility[recordTypes.size()];
prtv[0] = new ProfileRecordTypeVisibility();
prtv[0].setRecordType("abc");
prtv[0].setDefault(true);
prtv[0].setVisible(true);

Profile pr = new Profile();
pr.setRecordTypeVisibilities(prtv);
UpdateMetadata ut = new UpdateMetadata();
pr.setFullName("System_Administrator");
ut.setMetadata(pr);

So, I'm getting the Error like

com.sforce.ws.SoapFaultException: INVALID_CROSS_REFERENCE_KEY: In field: fullName - no Profile named System_Administrator found.

I have even tried System Administrator, Profile, Profile.System_Administrator but none worked for me.

The Salesforce doc says for the Profile object's fullName field: It must be specified when creating, updating, or deleting.

Please let me know what I'm doing wrong or is there anything else I can go for.

Thanks

  • 2
    I logged in to my org via workbench.developerforce.com/login.php and used the Metadata Query feature to list the profiles and I don't see System Administrator. Can you perform this action via the UI out of interest? Also have you tried doing this on a custom profile? – Andrew Fawcett Sep 6 '13 at 7:53
8

I have found the solution by using fullName Admin which is got by querying Profile Object using listMetadata() method of MetadataConnection. The list of fullName of Standard Profiles then returned are as follows:

SolutionManager
Customer Portal Manager Standard
StandardAul
Standard
Chatter Free User
Chatter External User
ContractManager
Customer Portal Manager Custom
Silver Partner User
Chatter Moderator User
Custom%3A Sales Profile
Partner App Subscription
Admin
Force%2Ecom - Free User
MarketingProfile
Custom%3A Marketing Profile
HighVolumePortal
Custom%3A Support Profile
Force%2Ecom - App Subscription User
Gold Partner User
PlatformPortal
ReadOnly

Thanks to Andrew who has given this idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.