You need to sign in to do that
Don't have an account?
I want to create sobject in test class.
can't really do something like:
Schema.getGlobalDescribe().get(ObjectName).newSObject() ;
Schema.getGlobalDescribe().get(ObjectName).newSObject() ;
You need to sign in to do that
Don't have an account?
You can use the below code to create Sobject in test class: In place of Account you can use your custom object for which you want to create test Sobject.
Please find more help on below link :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_SObjectType.htm
Let me know if you need more help.
Thanks,
Abhishek
i am taking currentpageid and object name from that id in my controller:
currentPageId =ApexPages.currentPage().getParameters().get('Id');
ObjName = id.ValueOf(currentPageId).getSObjectType().getDescribe().getName();
Try this:
Please let me know if this helps.
If yes, please mark the Question as Solved.
Thanks and Regards,
Anirudh Singh