You need to sign in to do that
Don't have an account?
Error explanation
Account Clientacc;
I have executed the following query
Clientacc =new Account(LastName='ABC',PersonMailingStreet='Street',PersonMailingCity='City',
PersonMailingState='state',PersonMailingCountry='country',
PersonMailingPostalCode='123456',FirstName='DEF',Retirement_Age__c='55',
Estimated_Life_Expectancy__c='85',PersonBirthdate=system.today(), RecordTypeId='01220000000DnK3AAK');
upsert Clientacc;
when i execute this query with out upsert statement it does not give me any error.
it shows me successfully executed
but when i execute the upsert statment it shows upsert failed. The error which is shown is as follows
11:29:45:018 EXCEPTION_THROWN [2]|System.DmlException: Upsert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: id value not valid for the users profile: 01220000000HZ0HAAW: [RecordTypeId]
I know this i hard codded ID which is been used n i have tried every way to solve this but not able to can i please get an help on the same
May be your hard coded RecordTypeID is not visible to the used profile.
Check your record type setting in your profile for account object.
The record type that you are assigning might be not available for the creating user profile , please checkmin profile list whether the allocated recordtype is available for user or not.
or you can write your query like--------
Task t=new Task(WhatId=opp.id);
t.Type='To Do';
t.Activity_Purpose__c='Requested';
t.ActivityDate=System.today()+7;
t.OwnerId=userid;
t.Subject='RFP Info Requested';
t.Priority='Normal';
t.Status='Not Started';
t.RecordType=new RecordType(name='Client Task Record type');
upsert t;
ya the ID is not getting fetched as its not available in my user profile.
i am refering to this code an creating my application.
can u tel me how do i get the user ID for my insert query.
some how its a mandatory field so cant execute the query with out the recordType Id.
Kindly help me with the same....
Record type id is not a mandattory field skip that field.
If i execute the query with out RecordTyppeId this is the error msg that i am getting
12:52:31:019 FATAL_ERROR System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, record type missing for: Account: []