Dynamic Apex: Write test class for this apex code(Not required the output) You are working on the project in which you have to create the apex code in which your task is to define the objects...


Dynamic Apex: Write test class for this apex code(Not required the output)<br>You are working on the project in which you have to create the apex code in which your task<br>is to define the objects dynamically by using the method argument which is api name in<br>string and a map of string, string as a key value pair.<br>Class Code:<br>public static void modifySobjectData(String str , Map<String ,String> mapofString)<br>{<br>//Retrive the type of Sobject by using the getGlobalDescribe<br>Schema.SobjectType targetType = Schema.getGlobalDescribe().get(str);<br>//Initalize the Object<br>Sobject newobject = targetType.newSobject();<br>for (String s :mapofString.keySet()<br>{<br>newobject.put(s, mapofString.get(s));<br>}<br>System.debug('newObject' + newobject);<br>//Perform the DML<br>if(targetType != null)<br>insert newobject;<br>}<br>}<br>

Extracted text: Dynamic Apex: Write test class for this apex code(Not required the output) You are working on the project in which you have to create the apex code in which your task is to define the objects dynamically by using the method argument which is api name in string and a map of string, string as a key value pair. Class Code: public static void modifySobjectData(String str , Map mapofString) { //Retrive the type of Sobject by using the getGlobalDescribe Schema.SobjectType targetType = Schema.getGlobalDescribe().get(str); //Initalize the Object Sobject newobject = targetType.newSobject(); for (String s :mapofString.keySet() { newobject.put(s, mapofString.get(s)); } System.debug('newObject' + newobject); //Perform the DML if(targetType != null) insert newobject; } }

Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here