You need to sign in to do that
Don't have an account?
o raju
How to give save functionality Dynamically comming object through URL?
Hi,
Here object name through URL will come look like
https://Raju.ap1.visual.force.com/apex/Dynamicsetpage?DFN=ramobj
In My apex class i get this objects as using schema method and i displayed all fields
strtemp=ApexPages.currentPage().getParameters().get('DFN');
this.DFN=strtemp;
system.debug('*********objectselected//**********'+strtemp);
String strFieldName = 'raju__'+DFN + '__c'; //Object name
system.debug('*********objects**********'+strtemp);
My Question:How to give save functonality of this Dyamically getting object?
help me..........
Here object name through URL will come look like
https://Raju.ap1.visual.force.com/apex/Dynamicsetpage?DFN=ramobj
In My apex class i get this objects as using schema method and i displayed all fields
strtemp=ApexPages.currentPage().getParameters().get('DFN');
this.DFN=strtemp;
system.debug('*********objectselected//**********'+strtemp);
String strFieldName = 'raju__'+DFN + '__c'; //Object name
system.debug('*********objects**********'+strtemp);
My Question:How to give save functonality of this Dyamically getting object?
help me..........
in your question you mentioned that you are passing the object name in the URL.. but seems you are passing in the field name..
the code will work if you pass in the object name..
if your URL is
https://Raju.ap1.visual.force.com/apex/Dynamicsetpage?DFN=ramobj
and ramobj is your Object Name, then your code should be
All Answers
you can try something like this
Thank u for Reply,
I try to above code like this
public void doSave() {
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(strFieldName);
System.debug('******targetType*******'+targetType);
SObject myObj = targetType.newSObject();
System.debug('*****myObj*******'+myObj);
insert myObj;
}
I got following error :
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doSave}' in component <apex:commandButton> in page raju:dynamicfieldsetpage
Class.Bisoftsols.DynamicBinding.doSave: line 9, column 1/
Here:line 9 meansSObject myObj = targetType.newSObject();
And object name is---> strFieldName(look like string strFieldName = 'Raju__'+strtemp + '__c';)
Help me.............
in your question you mentioned that you are passing the object name in the URL.. but seems you are passing in the field name..
the code will work if you pass in the object name..
if your URL is
https://Raju.ap1.visual.force.com/apex/Dynamicsetpage?DFN=ramobj
and ramobj is your Object Name, then your code should be
It's working fine Thank you but in an object records inserted but I gave some field values(like amount,name) related to object and click save only record inserted related object but fields values not inserted in database.
How to insert field values also ?
Help me...........
Only Records created related object, but i gave some fields those field values not saved in that records.
please help me.......