You need to sign in to do that
Don't have an account?

formula field
Hi,
I have created an custom object product and it has so many field but the problem is that when i am trying to create a test class in which i am inserting date then it is giving error that the field is not writable.
I have used formula in InHometrgtdateminus13days__c = In_Home_Target_Date__c-13
Products__c ps = new Products__c();
ps.ms_123postcards__Account__c = comp.id;
ps.Fulfillment_Status__c = 'Currently in Design';
ps.In_Home_Target_Date__c = system.today().adddays(13);
ps.To_Finalize_Design__c = False;
Ps.Do_not_repeat_finalize_design_task__c = FALSE;
ps.Receive_New_Agreement__c = system.today().adddays(-1);
ps.InHometrgtdateminus13days__c = system.today();
insert ps;
This error is giving when i am trying to insert ps.InHometrgtdateminus13days__c = system.today();
Can anyone help me to resolve this issue?
I have created an custom object product and it has so many field but the problem is that when i am trying to create a test class in which i am inserting date then it is giving error that the field is not writable.
I have used formula in InHometrgtdateminus13days__c = In_Home_Target_Date__c-13
Products__c ps = new Products__c();
ps.ms_123postcards__Account__c = comp.id;
ps.Fulfillment_Status__c = 'Currently in Design';
ps.In_Home_Target_Date__c = system.today().adddays(13);
ps.To_Finalize_Design__c = False;
Ps.Do_not_repeat_finalize_design_task__c = FALSE;
ps.Receive_New_Agreement__c = system.today().adddays(-1);
ps.InHometrgtdateminus13days__c = system.today();
insert ps;
This error is giving when i am trying to insert ps.InHometrgtdateminus13days__c = system.today();
Can anyone help me to resolve this issue?
Please find below reasons for this error:
date finalizedisgntaskdate = system.today();
prodserv = [select ms_123postcards__Account__c, id, Fulfillment_Status__c from Products__c where InHometrgtdateminus13days__c = :finalizedisgntaskdate];
Fectch the formula field in your query.
date finalizedisgntaskdate = system.today();
prodserv = [select ms_123postcards__Account__c, id,InHometrgtdateminus13days__c, Fulfillment_Status__c from Products__c where InHometrgtdateminus13days__c = :finalizedisgntaskdate];
and then try.
If this won't help, can you share abstract form of your class and test class to understand real issue.
The problem is that i can not change query that is in the class.
Without making any changes in the class i want to increase code coverage.