-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
16Questions
-
20Replies
When quote status is equal to "ready to price" or "proposed" and quote expiration date is today, move quote status to expired. Need an Apex Scheduler class. Please advice
Hi All,
I want to create a scheduler class. When quote status is equal to "ready to price" or "proposed" and quote expiration date is today, move quote status to expired. Please advice
I want to create a scheduler class. When quote status is equal to "ready to price" or "proposed" and quote expiration date is today, move quote status to expired. Please advice
- Veerendar Aella
- May 01, 2019
- Like
- 0
- Continue reading or reply
I want to send warning email alerts to users who's last login greater than 90 days.
I want to send warning email alerts to users who's last login greater than 90 days. Please help.
- Veerendar Aella
- March 07, 2019
- Like
- 0
- Continue reading or reply
- Veerendar Aella
- March 01, 2019
- Like
- 0
- Continue reading or reply
Need a trigger to more quote status from ready to price to Proposed when a quote option is created
Hi All, I want a trigger to move quote status from ready to price to proposed when a quote option is created. Here Quote is the Parent Object and Quote Option is the child. So, when ever a quote option is created, I want to move my quote status to proposed. Please hlep.
Please also need test class for the trigger.
Please also need test class for the trigger.
- Veerendar Aella
- February 06, 2019
- Like
- 0
- Continue reading or reply
Need 75 plus test coverage for the apex trigger
Hi All,
I need a test coverage of 75% plus for the below trigger, Please help.
trigger example on Lead (before insert, before update)
{
system.debug('In Assign Contractor 2.1');
static string pcode;
Map<Id, String> mLedvsZip = new Map<Id, String>();
Map<String, List<Id>> mZipvsLeads = new Map<String, List<Id>>();
system.debug(Trigger.new);
for(Lead led: Trigger.new){
system.debug('Trigger New loop:');
if(led.PostalCode <> null && led.PostalCode.length() >= 5) {
pcode = led.PostalCode.substring(0,5);
}
if(led.CTrigger__c && led.WG_Status__c == 'Gas Available'){
system.debug('In led.ctrigger loop');
system.debug('In led.PostalCode: ' + led.PostalCode );
system.debug('In led.Contractor: ' + led.Contractor__c);
if( led.Contractor__c == null && String.isNotBlank(led.PostalCode)){
system.debug('initial zip: ' + led.PostalCode);
system.debug('truncated zip: ' + pcode);
if(led.PostalCode.length() >= 5) {
system.debug('mLedvsZip Put: ' + pcode);
mLedvsZip.put(led.Id, pcode);
}
else
{
system.debug('>>>>>> invalid zip found: ' + led.PostalCode);
}
if(!mZipvsLeads.isEmpty() && mZipvsLeads.containsKey(pcode)){
List<Id> tempIds = mZipvsLeads.get(pcode);
tempIds.add(led.Id);
mZipvsLeads.put(pcode, tempIds);
}
else if(!mZipvsLeads.isEmpty() && !mZipvsLeads.containsKey(pcode))
mZipvsLeads.put(pcode, new List<Id>{led.Id});
else if(mZipvsLeads.isEmpty())
mZipvsLeads.put(pcode, new List<Id>{led.Id});
}
}
}//End For
if(!mZipvsLeads.isEmpty()){
List<Zip_Code__c> lstZC = [SELECT Zip_Code__c,
Name, Account__c,
Account__r.Last_Lead_Assign_Date__c
FROM Zip_Code__c
WHERE Zip_Code__c IN: mZipvsLeads.keySet() AND
Account__r.Accept_Leads__c = true
ORDER BY Account__r.Last_Gas_Available_Lead_Assigned__c ASC NULLS FIRST];
system.debug('List from SQL: ' + lstZC);
if(!lstZC.isEmpty()){
Map<String, List<Id>> mZCvAccs = new Map<String, List<Id>>();//Zip vs associatd Accounts
for(Zip_Code__c zc: lstZC){
if(!mZCvAccs.isEmpty() && mZCvAccs.containsKey(zc.Zip_Code__c)){
List<Id> tempIds = mZCvAccs.get(zc.Zip_Code__c);
tempIds.add(zc.Account__c);
mZCvAccs.put(zc.Zip_Code__c, tempIds);
}
else if(!mZCvAccs.isEmpty() && !mZCvAccs.containsKey(zc.Zip_Code__c))
mZCvAccs.put(zc.Zip_Code__c, new List<Id>{zc.Account__c});
else if(mZCvAccs.isEmpty())
mZCvAccs.put(zc.Zip_Code__c, new List<Id>{zc.Account__c});
}
if(!mZipvsLeads.isEmpty() && !mZCvAccs.isEmpty()){
Map<Id, DateTime> mAcctoUpdate = new Map<Id, DateTime>();//Account to Update for Datetime of Assignement
for(String zip: mZipvsLeads.keySet()){
List<Id> lstLeads = mZipvsLeads.get(zip);
List<Id> lstAccounts = mZCvAccs.get(zip);
if(lstLeads.size()==1){
if(!lstAccounts.isEmpty() && lstAccounts.size() == 1){
if(Trigger.isInsert)
trigger.new[0].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[0]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
else if(!lstAccounts.isEmpty() && lstAccounts.size() > 1){
if(Trigger.isInsert)
trigger.new[0].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[0]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
}
else if(lstLeads.size()>1){
if(!lstAccounts.isEmpty() && lstAccounts.size() == 1){
for(Integer i=0; i<lstLeads.size(); i++){
if(Trigger.isInsert)
trigger.new[i].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[i]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
}
else if(!lstAccounts.isEmpty() && lstAccounts.size() > 1){
if(lstLeads.size() <= lstAccounts.size()){
for(Integer i=0; i<lstLeads.size(); i++){
if(Trigger.isInsert)
trigger.new[i].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[i]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[i], DateTime.now());
}
}
else if(lstLeads.size() > lstAccounts.size()){
List<List<Id>> lstlstId = Util.CreatePackets(lstAccounts.size(), lstLeads);
for(Integer i=0; i<lstlstId.size(); i++){
for(Integer j=0; j<lstlstId[i].size(); j++){
trigger.newMap.get(lstlstId[i][j]).Contractor__c = lstAccounts[j];
mAcctoUpdate.put(lstAccounts[i], DateTime.now());
}
}
}
}
}
}
if(!mAcctoUpdate.isEmpty()){
List<Account> lstAccUp = new List<Account>();
for(Id accId: mAcctoUpdate.keySet())
lstAccUp.add(new Account(id= accId,
Last_Gas_Available_Lead_Assigned__c = mAcctoUpdate.get(accId)));
if(!lstAccUp.isEmpty())
update lstAccUp;
}
}
}
}
// Update Contractor Email
Set<id> acctIds = new Set<id>();
system.debug('Trigger NEW: '+ Trigger.new);
for(Lead led: trigger.new){
// Lead oldLead = Trigger.oldMap.get(led.ID);
acctIds.add(led.Contractor__c);
}
system.debug('Acctids: '+ acctids);
// create a map so that Account is locatable by its Id (key)
Map<id, account> acctsMap = new Map<id, account>(
[SELECT Id, Partner_Email__c,Partner_Secondary_Email__c FROM Account WHERE id IN :acctIds]);
system.debug('AcctsMap: ' + acctsMap);
for (Lead led : Trigger.new) {
if(led.CTrigger__c && !led.Contractor_Contact__c){
// led.CTrigger__c = False;
}
if (led.Contractor__c != null){
led.Contractor_Email__c = acctsMap.get(led.Contractor__c).Partner_Email__c;
led.Contractor_Secondary_Email__c = acctsMap.get(led.Contractor__c).Partner_Secondary_Email__c;
led.Contractor_Assignment_Status__c = 'Assigned';
}
else
{
led.Contractor_Email__c = '';
led.Contractor_Secondary_Email__c = '';
if(led.CTrigger__c) {
led.Contractor_Assignment_Status__c = 'No Contractor Found';}
else
{
led.Contractor_Assignment_Status__c = '';
}
}
}
}
I need a test coverage of 75% plus for the below trigger, Please help.
trigger example on Lead (before insert, before update)
{
system.debug('In Assign Contractor 2.1');
static string pcode;
Map<Id, String> mLedvsZip = new Map<Id, String>();
Map<String, List<Id>> mZipvsLeads = new Map<String, List<Id>>();
system.debug(Trigger.new);
for(Lead led: Trigger.new){
system.debug('Trigger New loop:');
if(led.PostalCode <> null && led.PostalCode.length() >= 5) {
pcode = led.PostalCode.substring(0,5);
}
if(led.CTrigger__c && led.WG_Status__c == 'Gas Available'){
system.debug('In led.ctrigger loop');
system.debug('In led.PostalCode: ' + led.PostalCode );
system.debug('In led.Contractor: ' + led.Contractor__c);
if( led.Contractor__c == null && String.isNotBlank(led.PostalCode)){
system.debug('initial zip: ' + led.PostalCode);
system.debug('truncated zip: ' + pcode);
if(led.PostalCode.length() >= 5) {
system.debug('mLedvsZip Put: ' + pcode);
mLedvsZip.put(led.Id, pcode);
}
else
{
system.debug('>>>>>> invalid zip found: ' + led.PostalCode);
}
if(!mZipvsLeads.isEmpty() && mZipvsLeads.containsKey(pcode)){
List<Id> tempIds = mZipvsLeads.get(pcode);
tempIds.add(led.Id);
mZipvsLeads.put(pcode, tempIds);
}
else if(!mZipvsLeads.isEmpty() && !mZipvsLeads.containsKey(pcode))
mZipvsLeads.put(pcode, new List<Id>{led.Id});
else if(mZipvsLeads.isEmpty())
mZipvsLeads.put(pcode, new List<Id>{led.Id});
}
}
}//End For
if(!mZipvsLeads.isEmpty()){
List<Zip_Code__c> lstZC = [SELECT Zip_Code__c,
Name, Account__c,
Account__r.Last_Lead_Assign_Date__c
FROM Zip_Code__c
WHERE Zip_Code__c IN: mZipvsLeads.keySet() AND
Account__r.Accept_Leads__c = true
ORDER BY Account__r.Last_Gas_Available_Lead_Assigned__c ASC NULLS FIRST];
system.debug('List from SQL: ' + lstZC);
if(!lstZC.isEmpty()){
Map<String, List<Id>> mZCvAccs = new Map<String, List<Id>>();//Zip vs associatd Accounts
for(Zip_Code__c zc: lstZC){
if(!mZCvAccs.isEmpty() && mZCvAccs.containsKey(zc.Zip_Code__c)){
List<Id> tempIds = mZCvAccs.get(zc.Zip_Code__c);
tempIds.add(zc.Account__c);
mZCvAccs.put(zc.Zip_Code__c, tempIds);
}
else if(!mZCvAccs.isEmpty() && !mZCvAccs.containsKey(zc.Zip_Code__c))
mZCvAccs.put(zc.Zip_Code__c, new List<Id>{zc.Account__c});
else if(mZCvAccs.isEmpty())
mZCvAccs.put(zc.Zip_Code__c, new List<Id>{zc.Account__c});
}
if(!mZipvsLeads.isEmpty() && !mZCvAccs.isEmpty()){
Map<Id, DateTime> mAcctoUpdate = new Map<Id, DateTime>();//Account to Update for Datetime of Assignement
for(String zip: mZipvsLeads.keySet()){
List<Id> lstLeads = mZipvsLeads.get(zip);
List<Id> lstAccounts = mZCvAccs.get(zip);
if(lstLeads.size()==1){
if(!lstAccounts.isEmpty() && lstAccounts.size() == 1){
if(Trigger.isInsert)
trigger.new[0].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[0]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
else if(!lstAccounts.isEmpty() && lstAccounts.size() > 1){
if(Trigger.isInsert)
trigger.new[0].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[0]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
}
else if(lstLeads.size()>1){
if(!lstAccounts.isEmpty() && lstAccounts.size() == 1){
for(Integer i=0; i<lstLeads.size(); i++){
if(Trigger.isInsert)
trigger.new[i].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[i]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[0], DateTime.now());
}
}
else if(!lstAccounts.isEmpty() && lstAccounts.size() > 1){
if(lstLeads.size() <= lstAccounts.size()){
for(Integer i=0; i<lstLeads.size(); i++){
if(Trigger.isInsert)
trigger.new[i].Contractor__c = lstAccounts[0];
else if(Trigger.isUpdate)
trigger.newMap.get(lstLeads[i]).Contractor__c = lstAccounts[0];
mAcctoUpdate.put(lstAccounts[i], DateTime.now());
}
}
else if(lstLeads.size() > lstAccounts.size()){
List<List<Id>> lstlstId = Util.CreatePackets(lstAccounts.size(), lstLeads);
for(Integer i=0; i<lstlstId.size(); i++){
for(Integer j=0; j<lstlstId[i].size(); j++){
trigger.newMap.get(lstlstId[i][j]).Contractor__c = lstAccounts[j];
mAcctoUpdate.put(lstAccounts[i], DateTime.now());
}
}
}
}
}
}
if(!mAcctoUpdate.isEmpty()){
List<Account> lstAccUp = new List<Account>();
for(Id accId: mAcctoUpdate.keySet())
lstAccUp.add(new Account(id= accId,
Last_Gas_Available_Lead_Assigned__c = mAcctoUpdate.get(accId)));
if(!lstAccUp.isEmpty())
update lstAccUp;
}
}
}
}
// Update Contractor Email
Set<id> acctIds = new Set<id>();
system.debug('Trigger NEW: '+ Trigger.new);
for(Lead led: trigger.new){
// Lead oldLead = Trigger.oldMap.get(led.ID);
acctIds.add(led.Contractor__c);
}
system.debug('Acctids: '+ acctids);
// create a map so that Account is locatable by its Id (key)
Map<id, account> acctsMap = new Map<id, account>(
[SELECT Id, Partner_Email__c,Partner_Secondary_Email__c FROM Account WHERE id IN :acctIds]);
system.debug('AcctsMap: ' + acctsMap);
for (Lead led : Trigger.new) {
if(led.CTrigger__c && !led.Contractor_Contact__c){
// led.CTrigger__c = False;
}
if (led.Contractor__c != null){
led.Contractor_Email__c = acctsMap.get(led.Contractor__c).Partner_Email__c;
led.Contractor_Secondary_Email__c = acctsMap.get(led.Contractor__c).Partner_Secondary_Email__c;
led.Contractor_Assignment_Status__c = 'Assigned';
}
else
{
led.Contractor_Email__c = '';
led.Contractor_Secondary_Email__c = '';
if(led.CTrigger__c) {
led.Contractor_Assignment_Status__c = 'No Contractor Found';}
else
{
led.Contractor_Assignment_Status__c = '';
}
}
}
}
- Veerendar Aella
- February 06, 2019
- Like
- 0
- Continue reading or reply
i want to automate last login users greater than 30 days , an email as to be sent to managers with the same.
Hi All,
When a last login user is greater than 30 days, then I want to send a automated email to the respective managers.
This can done by using
workflow
Process Builder
apex class
Please advice
When a last login user is greater than 30 days, then I want to send a automated email to the respective managers.
This can done by using
workflow
Process Builder
apex class
Please advice
- Veerendar Aella
- January 10, 2019
- Like
- 0
- Continue reading or reply
Do we have to add test methods manually while creating a package?
Hi All,
I am trying to create a package, during upload process getting below error even though i have code coverage more than 75% for my test classes.
Please help me.
Error: No test methods found in the Apex code included in the package. At least 75% test coverage is required.
I am trying to create a package, during upload process getting below error even though i have code coverage more than 75% for my test classes.
Please help me.
Error: No test methods found in the Apex code included in the package. At least 75% test coverage is required.
- Veerendar Aella
- December 07, 2018
- Like
- 0
- Continue reading or reply
Visualforce Error Help for this Page System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Hi All,
I am getting the above error when i try to import an xml file into the org, please help.
Error:
Visualforce Error
Help for this Page
System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Error is in expression '{!doUpload}' in component <apex:commandButton> in page importoppxml: Class.ImportOppXML.doUpload: line 124, column 1
Class.ImportOppXML.doUpload: line 124, column 1
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= decimal.valueof(child.gettext().trim());
} else if (child.getName() == 'CloseDate') {
r.CloseDate= Date.valueof(child.getText().trim());
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
VF:
<apex:page Controller="ImportOppXML">
<apex:form >
<apex:pageblock title="Import Opportunities From XML" id="PB">
<!-- inputFile for uploading XML -->
<apex:pageblocksection >
<apex:pageblocksectionitem >
<apex:outputLabel value="Please Select XML File:"/>
<apex:inputFile value="{!myfile}"> </apex:inputFile>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<!-- Table to show the XML Result -->
<apex:pageblocksection title="Result of XML file" columns="1" rendered="{!reports.size != null}">
<apex:pageblocktable value="{!reports}" var="opp">
<apex:column value="{!opp.Name}" headerValue="Name" />
<apex:column value="{!opp.Amount}" headerValue="Amount" />
<apex:column value="{!opp.CloseDate}" headerValue="CloseDate" />
<apex:column value="{!opp.Description}" headerValue="Description" />
<apex:column value="{!opp.LeadSource}" headerValue="LeadSource" />
<apex:column value="{!opp.NextStep}" headerValue="NextStep" />
<apex:column value="{!opp.StageName}" headerValue="StageName" />
<apex:column value="{!opp.Type}" headerValue="Type" />
</apex:pageblocktable>
</apex:pageblocksection>
<!-- Button for calling method of controller -->
<center>
<apex:commandButton value="Import Opportunities" action="{!doUpload}"/>
</center>
</apex:pageblock>
</apex:form>
</apex:page>
XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Opp-data >
<record>
<Name>zipzip</Name>
<Amount>65023</Amount>
<CloseDate>2018-12-18</<CloseDate>
<StageName>Prospecting</StageName>
</record>
</Opp-data>
I am getting the above error when i try to import an xml file into the org, please help.
Error:
Visualforce Error
Help for this Page
System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Error is in expression '{!doUpload}' in component <apex:commandButton> in page importoppxml: Class.ImportOppXML.doUpload: line 124, column 1
Class.ImportOppXML.doUpload: line 124, column 1
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= decimal.valueof(child.gettext().trim());
} else if (child.getName() == 'CloseDate') {
r.CloseDate= Date.valueof(child.getText().trim());
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
VF:
<apex:page Controller="ImportOppXML">
<apex:form >
<apex:pageblock title="Import Opportunities From XML" id="PB">
<!-- inputFile for uploading XML -->
<apex:pageblocksection >
<apex:pageblocksectionitem >
<apex:outputLabel value="Please Select XML File:"/>
<apex:inputFile value="{!myfile}"> </apex:inputFile>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<!-- Table to show the XML Result -->
<apex:pageblocksection title="Result of XML file" columns="1" rendered="{!reports.size != null}">
<apex:pageblocktable value="{!reports}" var="opp">
<apex:column value="{!opp.Name}" headerValue="Name" />
<apex:column value="{!opp.Amount}" headerValue="Amount" />
<apex:column value="{!opp.CloseDate}" headerValue="CloseDate" />
<apex:column value="{!opp.Description}" headerValue="Description" />
<apex:column value="{!opp.LeadSource}" headerValue="LeadSource" />
<apex:column value="{!opp.NextStep}" headerValue="NextStep" />
<apex:column value="{!opp.StageName}" headerValue="StageName" />
<apex:column value="{!opp.Type}" headerValue="Type" />
</apex:pageblocktable>
</apex:pageblocksection>
<!-- Button for calling method of controller -->
<center>
<apex:commandButton value="Import Opportunities" action="{!doUpload}"/>
</center>
</apex:pageblock>
</apex:form>
</apex:page>
XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Opp-data >
<record>
<Name>zipzip</Name>
<Amount>65023</Amount>
<CloseDate>2018-12-18</<CloseDate>
<StageName>Prospecting</StageName>
</record>
</Opp-data>
- Veerendar Aella
- December 05, 2018
- Like
- 0
- Continue reading or reply
Illegal assignment from String to Decimal, Please help.
Hi All,
Below is my Code for Importing XML into Salesforce org.
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= child.gettext().trim();
} else if (child.getName() == 'CloseDate') {
r.CloseDate= child.getText().trim();
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
Below is my Code for Importing XML into Salesforce org.
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= child.gettext().trim();
} else if (child.getName() == 'CloseDate') {
r.CloseDate= child.getText().trim();
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
- Veerendar Aella
- December 05, 2018
- Like
- 0
- Continue reading or reply
need test class for apex class Import Json
Hi All,
I have an Apex class for importing Json file into the salesforce org, I need a test for this apex code. Please help.
Apex Code:
public class ParserJson_New{
public Blob myfile{get;set;}
public ParserJson_New(){
reports = new fromJSON();
}
public fromJSON reports {get;set;}
public void doUpload() {
System.debug('myfile'+myfile.toString());
reports = (fromJSON) System.JSON.deserialize(myfile.toString(), fromJSON.class);
List<cls_record> rec = reports.leaddata.record ;
List<Lead> leadList = new List<Lead>();
for(cls_record c :rec){
leadList.add( new Lead( FirstName =c.FirstName ,LastName = c.LastName , Phone =c.Phone ,
Email =c.Email, Company =c.Company, Fax =c.Fax, Description =c.Description
, Industry =c.Industry, Status =c.Status, Website =c.Website, LeadSource =c.LeadSource));
}
insert leadList;
}
public class fromJSON{
public cls_leaddata leaddata{get;set;}
}
public class cls_leaddata {
public cls_record[] record{get;set;}
}
public class cls_record {
public String FirstName{get;set;}
public String LastName{get;set;}
public String Phone{get;set;}
public String Email{get;set;}
public String Company{get;set;}
public String Fax{get;set;}
public String Description{get;set;}
public String Industry{get;set;}
public String Status{get;set;}
public String Website{get;set;}
public String LeadSource{get;set;}
}
}
Json File:
{
"leaddata": {
"record": [
{
"FirstName": "Zepra",
"LastName": "Json",
"Phone": "8008237678",
"Email": "Zepra@gmail.com",
"Company": "Zepra Inc",
"Fax": "143215",
"Industry": "Zepra",
"Description": "This is my Zepra Json",
"Status": "Working -Contacted",
"Website": "WWW.ZepraJson.com",
"LeadSource": "Web"
}
]
}
}
I have an Apex class for importing Json file into the salesforce org, I need a test for this apex code. Please help.
Apex Code:
public class ParserJson_New{
public Blob myfile{get;set;}
public ParserJson_New(){
reports = new fromJSON();
}
public fromJSON reports {get;set;}
public void doUpload() {
System.debug('myfile'+myfile.toString());
reports = (fromJSON) System.JSON.deserialize(myfile.toString(), fromJSON.class);
List<cls_record> rec = reports.leaddata.record ;
List<Lead> leadList = new List<Lead>();
for(cls_record c :rec){
leadList.add( new Lead( FirstName =c.FirstName ,LastName = c.LastName , Phone =c.Phone ,
Email =c.Email, Company =c.Company, Fax =c.Fax, Description =c.Description
, Industry =c.Industry, Status =c.Status, Website =c.Website, LeadSource =c.LeadSource));
}
insert leadList;
}
public class fromJSON{
public cls_leaddata leaddata{get;set;}
}
public class cls_leaddata {
public cls_record[] record{get;set;}
}
public class cls_record {
public String FirstName{get;set;}
public String LastName{get;set;}
public String Phone{get;set;}
public String Email{get;set;}
public String Company{get;set;}
public String Fax{get;set;}
public String Description{get;set;}
public String Industry{get;set;}
public String Status{get;set;}
public String Website{get;set;}
public String LeadSource{get;set;}
}
}
Json File:
{
"leaddata": {
"record": [
{
"FirstName": "Zepra",
"LastName": "Json",
"Phone": "8008237678",
"Email": "Zepra@gmail.com",
"Company": "Zepra Inc",
"Fax": "143215",
"Industry": "Zepra",
"Description": "This is my Zepra Json",
"Status": "Working -Contacted",
"Website": "WWW.ZepraJson.com",
"LeadSource": "Web"
}
]
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
Need test class for apex class import xml into salesforce org
Hi All,
I have an apex class for importing xml data into salesforce org, I need a test class code to test the data. Please help.
Below is my apex class:
public class ImportAccountsXML {
public Blob myfile{get;set;}
public ImportAccountsXML(){
reports = new List<Account>();
}
public List<Account> reports {get;set;}
public class Accdata {
public String Name {get; set;}
public String AccountNumber {get; set;}
public String Phone {get; set;}
public String Industry {get; set;}
public String type {get; set;}
public String Description {get; set;}
public String Site {get; set;}
public String Ownership {get; set;}
public String Sic {get; set;}
public String Website {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
account r = new account();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'AccountNumber') {
r.AccountNumber= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Industry') {
r.Industry= child.getText().trim();
} else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}else if (child.getName() == 'Ownership') {
r.Ownership= child.getText().trim();
}else if (child.getName() == 'Sic') {
r.Sic= child.getText().trim();
}else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
}else if (child.getName() == 'Website') {
r.Website= child.getText().trim();
}else if (child.getName() == 'Site') {
r.Site= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
I have an apex class for importing xml data into salesforce org, I need a test class code to test the data. Please help.
Below is my apex class:
public class ImportAccountsXML {
public Blob myfile{get;set;}
public ImportAccountsXML(){
reports = new List<Account>();
}
public List<Account> reports {get;set;}
public class Accdata {
public String Name {get; set;}
public String AccountNumber {get; set;}
public String Phone {get; set;}
public String Industry {get; set;}
public String type {get; set;}
public String Description {get; set;}
public String Site {get; set;}
public String Ownership {get; set;}
public String Sic {get; set;}
public String Website {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
account r = new account();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'AccountNumber') {
r.AccountNumber= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Industry') {
r.Industry= child.getText().trim();
} else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}else if (child.getName() == 'Ownership') {
r.Ownership= child.getText().trim();
}else if (child.getName() == 'Sic') {
r.Sic= child.getText().trim();
}else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
}else if (child.getName() == 'Website') {
r.Website= child.getText().trim();
}else if (child.getName() == 'Site') {
r.Site= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
apex error: testMethod can only be used on methods of a top level type
Hi All,
I am getting above error in my test class at 16 and 40, below is my code.
Please help.
Apex class:
public class ImportCSV1 {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
public ImportCSV1(){
csvFileLines = new String[]{};
acclist = New List<Account>();
}
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Account accObj = new Account() ;
string[] csvRecordData = csvFileLines[i].split(',');
accObj.name = csvRecordData[0] ;
accObj.accountnumber = csvRecordData[1];
accObj.Phone = csvRecordData[2];
accObj.Industry = csvRecordData[3];
accObj.Type = csvRecordData[4];
accObj.Description = csvRecordData[5];
accObj.Website = csvRecordData[6];
accObj.Site = csvRecordData[7];
accObj.Ownership = csvRecordData[8];
accObj.Sic = csvRecordData[9];
acclist.add(accObj);
}
insert acclist;
}
catch (Exception e)
{
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
ApexPages.addMessage(errorMessage);
}
}
}
Apex test class:
@istest
public class Test1 {
public class ImportDataFromCSVControllerTest {
public String str = 'Name,AccountNumber,Phone,Industry\n Esha Patharabe,10001,989632145,Banking\n Trupti Nimje,10002,875469856,Banking';
String csvAsString;
String[] csvFileLines;
Blob csvFileBody;
public testmethod void testfileupload(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.csvFileBody = csvFileBody;
importData.importCSVFile();
Test.stopTest();
}
public testmethod void testfileuploadNegative(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.importCSVFile();
Test.stopTest();
}
}
}
I am getting above error in my test class at 16 and 40, below is my code.
Please help.
Apex class:
public class ImportCSV1 {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
public ImportCSV1(){
csvFileLines = new String[]{};
acclist = New List<Account>();
}
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Account accObj = new Account() ;
string[] csvRecordData = csvFileLines[i].split(',');
accObj.name = csvRecordData[0] ;
accObj.accountnumber = csvRecordData[1];
accObj.Phone = csvRecordData[2];
accObj.Industry = csvRecordData[3];
accObj.Type = csvRecordData[4];
accObj.Description = csvRecordData[5];
accObj.Website = csvRecordData[6];
accObj.Site = csvRecordData[7];
accObj.Ownership = csvRecordData[8];
accObj.Sic = csvRecordData[9];
acclist.add(accObj);
}
insert acclist;
}
catch (Exception e)
{
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
ApexPages.addMessage(errorMessage);
}
}
}
Apex test class:
@istest
public class Test1 {
public class ImportDataFromCSVControllerTest {
public String str = 'Name,AccountNumber,Phone,Industry\n Esha Patharabe,10001,989632145,Banking\n Trupti Nimje,10002,875469856,Banking';
String csvAsString;
String[] csvFileLines;
Blob csvFileBody;
public testmethod void testfileupload(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.csvFileBody = csvFileBody;
importData.importCSVFile();
Test.stopTest();
}
public testmethod void testfileuploadNegative(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.importCSVFile();
Test.stopTest();
}
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
how to setup excel connector with saleforce
Hi all,
I am using office 2007, and I want to setup excel connector. Please help me with step by step flow.
Thanks in advance.
I am using office 2007, and I want to setup excel connector. Please help me with step by step flow.
Thanks in advance.
- Veerendar Aella
- November 14, 2018
- Like
- 0
- Continue reading or reply
how to import JSON file into lead records from apex and visualforce page by using single click import button
Hi All,
I want to import Json file into my leads record using apex and visualforce page.
Please help.
I want to import Json file into my leads record using apex and visualforce page.
Please help.
- Veerendar Aella
- November 13, 2018
- Like
- 0
- Continue reading or reply
how to import xml data file into lead records using apex and visualforce page??
Hi All,
I want to import an xml file into my lead records using the apex code and visualforce page on a single click from the page.
here is my sample xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data >
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
Please help me out.
I want to import an xml file into my lead records using the apex code and visualforce page on a single click from the page.
here is my sample xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data >
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
Please help me out.
- Veerendar Aella
- November 13, 2018
- Like
- 0
- Continue reading or reply
apex code to visualforce page
Hi All,
I want to import xml file into salesforce using apex code from visualforce page.
Please find below details of XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
And my apex code is:
public class Parser_New{
public class leaddata {
public String FirstName {get; set;}
public String LastName {get; set;}
public String Phone {get; set;}
public String Email {get; set;}
}
public List<leaddata> parse(string toParse) {
List<leaddata> reports = new List<leaddata>();
DOM.Document doc = new DOM.Document();
doc.load(toParse);
parseReports(doc.getRootElement(), reports);
system.debug('DDDDDDDDDDDDDDDDDDDDDDDD'+ Reports);
return reports;
}
private void parseReports(DOM.XMLNode node, List<leaddata> reports) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
leaddata r = new leaddata();
parseReport(child, r);
reports.add(r);
}
}
}
private void parseReport(DOM.XMLNode node, leaddata r) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'FirstName') {
r.FirstName= child.getText().trim();
} else if (child.getName() == 'LastName') {
r.Lastname= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Email') {
r.Email= child.getText().trim();
}
}
}
}
I have no clue how to use this apex code in visualforce page to import xml file . Please help.
I want to import xml file into salesforce using apex code from visualforce page.
Please find below details of XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
And my apex code is:
public class Parser_New{
public class leaddata {
public String FirstName {get; set;}
public String LastName {get; set;}
public String Phone {get; set;}
public String Email {get; set;}
}
public List<leaddata> parse(string toParse) {
List<leaddata> reports = new List<leaddata>();
DOM.Document doc = new DOM.Document();
doc.load(toParse);
parseReports(doc.getRootElement(), reports);
system.debug('DDDDDDDDDDDDDDDDDDDDDDDD'+ Reports);
return reports;
}
private void parseReports(DOM.XMLNode node, List<leaddata> reports) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
leaddata r = new leaddata();
parseReport(child, r);
reports.add(r);
}
}
}
private void parseReport(DOM.XMLNode node, leaddata r) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'FirstName') {
r.FirstName= child.getText().trim();
} else if (child.getName() == 'LastName') {
r.Lastname= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Email') {
r.Email= child.getText().trim();
}
}
}
}
I have no clue how to use this apex code in visualforce page to import xml file . Please help.
- Veerendar Aella
- November 12, 2018
- Like
- 0
- Continue reading or reply
I want to send warning email alerts to users who's last login greater than 90 days.
I want to send warning email alerts to users who's last login greater than 90 days. Please help.
- Veerendar Aella
- March 07, 2019
- Like
- 0
- Continue reading or reply
Need a trigger to more quote status from ready to price to Proposed when a quote option is created
Hi All, I want a trigger to move quote status from ready to price to proposed when a quote option is created. Here Quote is the Parent Object and Quote Option is the child. So, when ever a quote option is created, I want to move my quote status to proposed. Please hlep.
Please also need test class for the trigger.
Please also need test class for the trigger.
- Veerendar Aella
- February 06, 2019
- Like
- 0
- Continue reading or reply
Visualforce Error Help for this Page System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Hi All,
I am getting the above error when i try to import an xml file into the org, please help.
Error:
Visualforce Error
Help for this Page
System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Error is in expression '{!doUpload}' in component <apex:commandButton> in page importoppxml: Class.ImportOppXML.doUpload: line 124, column 1
Class.ImportOppXML.doUpload: line 124, column 1
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= decimal.valueof(child.gettext().trim());
} else if (child.getName() == 'CloseDate') {
r.CloseDate= Date.valueof(child.getText().trim());
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
VF:
<apex:page Controller="ImportOppXML">
<apex:form >
<apex:pageblock title="Import Opportunities From XML" id="PB">
<!-- inputFile for uploading XML -->
<apex:pageblocksection >
<apex:pageblocksectionitem >
<apex:outputLabel value="Please Select XML File:"/>
<apex:inputFile value="{!myfile}"> </apex:inputFile>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<!-- Table to show the XML Result -->
<apex:pageblocksection title="Result of XML file" columns="1" rendered="{!reports.size != null}">
<apex:pageblocktable value="{!reports}" var="opp">
<apex:column value="{!opp.Name}" headerValue="Name" />
<apex:column value="{!opp.Amount}" headerValue="Amount" />
<apex:column value="{!opp.CloseDate}" headerValue="CloseDate" />
<apex:column value="{!opp.Description}" headerValue="Description" />
<apex:column value="{!opp.LeadSource}" headerValue="LeadSource" />
<apex:column value="{!opp.NextStep}" headerValue="NextStep" />
<apex:column value="{!opp.StageName}" headerValue="StageName" />
<apex:column value="{!opp.Type}" headerValue="Type" />
</apex:pageblocktable>
</apex:pageblocksection>
<!-- Button for calling method of controller -->
<center>
<apex:commandButton value="Import Opportunities" action="{!doUpload}"/>
</center>
</apex:pageblock>
</apex:form>
</apex:page>
XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Opp-data >
<record>
<Name>zipzip</Name>
<Amount>65023</Amount>
<CloseDate>2018-12-18</<CloseDate>
<StageName>Prospecting</StageName>
</record>
</Opp-data>
I am getting the above error when i try to import an xml file into the org, please help.
Error:
Visualforce Error
Help for this Page
System.XmlException: Failed to parse XML due to: expected name start and not < (position: TEXT seen ...<CloseDate>2018-12-18</<... @6:33)
Error is in expression '{!doUpload}' in component <apex:commandButton> in page importoppxml: Class.ImportOppXML.doUpload: line 124, column 1
Class.ImportOppXML.doUpload: line 124, column 1
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= decimal.valueof(child.gettext().trim());
} else if (child.getName() == 'CloseDate') {
r.CloseDate= Date.valueof(child.getText().trim());
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
VF:
<apex:page Controller="ImportOppXML">
<apex:form >
<apex:pageblock title="Import Opportunities From XML" id="PB">
<!-- inputFile for uploading XML -->
<apex:pageblocksection >
<apex:pageblocksectionitem >
<apex:outputLabel value="Please Select XML File:"/>
<apex:inputFile value="{!myfile}"> </apex:inputFile>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<!-- Table to show the XML Result -->
<apex:pageblocksection title="Result of XML file" columns="1" rendered="{!reports.size != null}">
<apex:pageblocktable value="{!reports}" var="opp">
<apex:column value="{!opp.Name}" headerValue="Name" />
<apex:column value="{!opp.Amount}" headerValue="Amount" />
<apex:column value="{!opp.CloseDate}" headerValue="CloseDate" />
<apex:column value="{!opp.Description}" headerValue="Description" />
<apex:column value="{!opp.LeadSource}" headerValue="LeadSource" />
<apex:column value="{!opp.NextStep}" headerValue="NextStep" />
<apex:column value="{!opp.StageName}" headerValue="StageName" />
<apex:column value="{!opp.Type}" headerValue="Type" />
</apex:pageblocktable>
</apex:pageblocksection>
<!-- Button for calling method of controller -->
<center>
<apex:commandButton value="Import Opportunities" action="{!doUpload}"/>
</center>
</apex:pageblock>
</apex:form>
</apex:page>
XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Opp-data >
<record>
<Name>zipzip</Name>
<Amount>65023</Amount>
<CloseDate>2018-12-18</<CloseDate>
<StageName>Prospecting</StageName>
</record>
</Opp-data>
- Veerendar Aella
- December 05, 2018
- Like
- 0
- Continue reading or reply
Illegal assignment from String to Decimal, Please help.
Hi All,
Below is my Code for Importing XML into Salesforce org.
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= child.gettext().trim();
} else if (child.getName() == 'CloseDate') {
r.CloseDate= child.getText().trim();
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
Below is my Code for Importing XML into Salesforce org.
Apex Code:
public class ImportOppXML {
public Blob myfile{get;set;}
public ImportOppXML(){
reports = new List<Opportunity>();
}
public List<Opportunity> reports {get;set;}
public class Oppdata {
public String Name {get; set;}
public Decimal Amount {get; set;}
public Date CloseDate {get; set;}
public String Description {get; set;}
public String LeadSource {get; set;}
public String NextStep {get; set;}
public String StageName {get; set;}
public String Type {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
opportunity r = new opportunity();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'Amount') {
r.Amount= child.gettext().trim();
} else if (child.getName() == 'CloseDate') {
r.CloseDate= child.getText().trim();
} else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
} else if (child.getName() == 'LeadSource') {
r.LeadSource= child.getText().trim();
}else if (child.getName() == 'NextStep') {
r.NextStep= child.getText().trim();
}else if (child.getName() == 'StageName') {
r.StageName= child.getText().trim();
}else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
- Veerendar Aella
- December 05, 2018
- Like
- 0
- Continue reading or reply
need test class for apex class Import Json
Hi All,
I have an Apex class for importing Json file into the salesforce org, I need a test for this apex code. Please help.
Apex Code:
public class ParserJson_New{
public Blob myfile{get;set;}
public ParserJson_New(){
reports = new fromJSON();
}
public fromJSON reports {get;set;}
public void doUpload() {
System.debug('myfile'+myfile.toString());
reports = (fromJSON) System.JSON.deserialize(myfile.toString(), fromJSON.class);
List<cls_record> rec = reports.leaddata.record ;
List<Lead> leadList = new List<Lead>();
for(cls_record c :rec){
leadList.add( new Lead( FirstName =c.FirstName ,LastName = c.LastName , Phone =c.Phone ,
Email =c.Email, Company =c.Company, Fax =c.Fax, Description =c.Description
, Industry =c.Industry, Status =c.Status, Website =c.Website, LeadSource =c.LeadSource));
}
insert leadList;
}
public class fromJSON{
public cls_leaddata leaddata{get;set;}
}
public class cls_leaddata {
public cls_record[] record{get;set;}
}
public class cls_record {
public String FirstName{get;set;}
public String LastName{get;set;}
public String Phone{get;set;}
public String Email{get;set;}
public String Company{get;set;}
public String Fax{get;set;}
public String Description{get;set;}
public String Industry{get;set;}
public String Status{get;set;}
public String Website{get;set;}
public String LeadSource{get;set;}
}
}
Json File:
{
"leaddata": {
"record": [
{
"FirstName": "Zepra",
"LastName": "Json",
"Phone": "8008237678",
"Email": "Zepra@gmail.com",
"Company": "Zepra Inc",
"Fax": "143215",
"Industry": "Zepra",
"Description": "This is my Zepra Json",
"Status": "Working -Contacted",
"Website": "WWW.ZepraJson.com",
"LeadSource": "Web"
}
]
}
}
I have an Apex class for importing Json file into the salesforce org, I need a test for this apex code. Please help.
Apex Code:
public class ParserJson_New{
public Blob myfile{get;set;}
public ParserJson_New(){
reports = new fromJSON();
}
public fromJSON reports {get;set;}
public void doUpload() {
System.debug('myfile'+myfile.toString());
reports = (fromJSON) System.JSON.deserialize(myfile.toString(), fromJSON.class);
List<cls_record> rec = reports.leaddata.record ;
List<Lead> leadList = new List<Lead>();
for(cls_record c :rec){
leadList.add( new Lead( FirstName =c.FirstName ,LastName = c.LastName , Phone =c.Phone ,
Email =c.Email, Company =c.Company, Fax =c.Fax, Description =c.Description
, Industry =c.Industry, Status =c.Status, Website =c.Website, LeadSource =c.LeadSource));
}
insert leadList;
}
public class fromJSON{
public cls_leaddata leaddata{get;set;}
}
public class cls_leaddata {
public cls_record[] record{get;set;}
}
public class cls_record {
public String FirstName{get;set;}
public String LastName{get;set;}
public String Phone{get;set;}
public String Email{get;set;}
public String Company{get;set;}
public String Fax{get;set;}
public String Description{get;set;}
public String Industry{get;set;}
public String Status{get;set;}
public String Website{get;set;}
public String LeadSource{get;set;}
}
}
Json File:
{
"leaddata": {
"record": [
{
"FirstName": "Zepra",
"LastName": "Json",
"Phone": "8008237678",
"Email": "Zepra@gmail.com",
"Company": "Zepra Inc",
"Fax": "143215",
"Industry": "Zepra",
"Description": "This is my Zepra Json",
"Status": "Working -Contacted",
"Website": "WWW.ZepraJson.com",
"LeadSource": "Web"
}
]
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
Need test class for apex class import xml into salesforce org
Hi All,
I have an apex class for importing xml data into salesforce org, I need a test class code to test the data. Please help.
Below is my apex class:
public class ImportAccountsXML {
public Blob myfile{get;set;}
public ImportAccountsXML(){
reports = new List<Account>();
}
public List<Account> reports {get;set;}
public class Accdata {
public String Name {get; set;}
public String AccountNumber {get; set;}
public String Phone {get; set;}
public String Industry {get; set;}
public String type {get; set;}
public String Description {get; set;}
public String Site {get; set;}
public String Ownership {get; set;}
public String Sic {get; set;}
public String Website {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
account r = new account();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'AccountNumber') {
r.AccountNumber= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Industry') {
r.Industry= child.getText().trim();
} else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}else if (child.getName() == 'Ownership') {
r.Ownership= child.getText().trim();
}else if (child.getName() == 'Sic') {
r.Sic= child.getText().trim();
}else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
}else if (child.getName() == 'Website') {
r.Website= child.getText().trim();
}else if (child.getName() == 'Site') {
r.Site= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
I have an apex class for importing xml data into salesforce org, I need a test class code to test the data. Please help.
Below is my apex class:
public class ImportAccountsXML {
public Blob myfile{get;set;}
public ImportAccountsXML(){
reports = new List<Account>();
}
public List<Account> reports {get;set;}
public class Accdata {
public String Name {get; set;}
public String AccountNumber {get; set;}
public String Phone {get; set;}
public String Industry {get; set;}
public String type {get; set;}
public String Description {get; set;}
public String Site {get; set;}
public String Ownership {get; set;}
public String Sic {get; set;}
public String Website {get; set;}
}
private void parseReports(DOM.XMLNode node) {
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'record') {
System.debug('child'+child);
parseReport(child);
// reports.add(r);
}
System.debug('reports'+reports);
}
}
private void parseReport(DOM.XMLNode node ) {
account r = new account();
for (Dom.XMLNode child : node.getChildElements()) {
if (child.getName() == 'Name') {
r.Name= child.getText().trim();
} else if (child.getName() == 'AccountNumber') {
r.AccountNumber= child.getText().trim();
} else if (child.getName() == 'Phone') {
r.Phone= child.getText().trim();
} else if (child.getName() == 'Industry') {
r.Industry= child.getText().trim();
} else if (child.getName() == 'Type') {
r.Type= child.getText().trim();
}else if (child.getName() == 'Ownership') {
r.Ownership= child.getText().trim();
}else if (child.getName() == 'Sic') {
r.Sic= child.getText().trim();
}else if (child.getName() == 'Description') {
r.Description= child.getText().trim();
}else if (child.getName() == 'Website') {
r.Website= child.getText().trim();
}else if (child.getName() == 'Site') {
r.Site= child.getText().trim();
}
}
reports.add(r);
upsert reports;
}
public void doUpload() {
DOM.Document doc = new DOM.Document();
doc.load(String.valueOf(myfile.toString()));
parseReports(doc.getRootElement());
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
apex error: testMethod can only be used on methods of a top level type
Hi All,
I am getting above error in my test class at 16 and 40, below is my code.
Please help.
Apex class:
public class ImportCSV1 {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
public ImportCSV1(){
csvFileLines = new String[]{};
acclist = New List<Account>();
}
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Account accObj = new Account() ;
string[] csvRecordData = csvFileLines[i].split(',');
accObj.name = csvRecordData[0] ;
accObj.accountnumber = csvRecordData[1];
accObj.Phone = csvRecordData[2];
accObj.Industry = csvRecordData[3];
accObj.Type = csvRecordData[4];
accObj.Description = csvRecordData[5];
accObj.Website = csvRecordData[6];
accObj.Site = csvRecordData[7];
accObj.Ownership = csvRecordData[8];
accObj.Sic = csvRecordData[9];
acclist.add(accObj);
}
insert acclist;
}
catch (Exception e)
{
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
ApexPages.addMessage(errorMessage);
}
}
}
Apex test class:
@istest
public class Test1 {
public class ImportDataFromCSVControllerTest {
public String str = 'Name,AccountNumber,Phone,Industry\n Esha Patharabe,10001,989632145,Banking\n Trupti Nimje,10002,875469856,Banking';
String csvAsString;
String[] csvFileLines;
Blob csvFileBody;
public testmethod void testfileupload(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.csvFileBody = csvFileBody;
importData.importCSVFile();
Test.stopTest();
}
public testmethod void testfileuploadNegative(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.importCSVFile();
Test.stopTest();
}
}
}
I am getting above error in my test class at 16 and 40, below is my code.
Please help.
Apex class:
public class ImportCSV1 {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
public ImportCSV1(){
csvFileLines = new String[]{};
acclist = New List<Account>();
}
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Account accObj = new Account() ;
string[] csvRecordData = csvFileLines[i].split(',');
accObj.name = csvRecordData[0] ;
accObj.accountnumber = csvRecordData[1];
accObj.Phone = csvRecordData[2];
accObj.Industry = csvRecordData[3];
accObj.Type = csvRecordData[4];
accObj.Description = csvRecordData[5];
accObj.Website = csvRecordData[6];
accObj.Site = csvRecordData[7];
accObj.Ownership = csvRecordData[8];
accObj.Sic = csvRecordData[9];
acclist.add(accObj);
}
insert acclist;
}
catch (Exception e)
{
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
ApexPages.addMessage(errorMessage);
}
}
}
Apex test class:
@istest
public class Test1 {
public class ImportDataFromCSVControllerTest {
public String str = 'Name,AccountNumber,Phone,Industry\n Esha Patharabe,10001,989632145,Banking\n Trupti Nimje,10002,875469856,Banking';
String csvAsString;
String[] csvFileLines;
Blob csvFileBody;
public testmethod void testfileupload(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.csvFileBody = csvFileBody;
importData.importCSVFile();
Test.stopTest();
}
public testmethod void testfileuploadNegative(){
Test.startTest();
csvFileBody = Blob.valueOf(str);
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
ImportCSV1 importData = new ImportCSV1();
importData.importCSVFile();
Test.stopTest();
}
}
}
- Veerendar Aella
- December 04, 2018
- Like
- 0
- Continue reading or reply
how to setup excel connector with saleforce
Hi all,
I am using office 2007, and I want to setup excel connector. Please help me with step by step flow.
Thanks in advance.
I am using office 2007, and I want to setup excel connector. Please help me with step by step flow.
Thanks in advance.
- Veerendar Aella
- November 14, 2018
- Like
- 0
- Continue reading or reply
how to import JSON file into lead records from apex and visualforce page by using single click import button
Hi All,
I want to import Json file into my leads record using apex and visualforce page.
Please help.
I want to import Json file into my leads record using apex and visualforce page.
Please help.
- Veerendar Aella
- November 13, 2018
- Like
- 0
- Continue reading or reply
how to import xml data file into lead records using apex and visualforce page??
Hi All,
I want to import an xml file into my lead records using the apex code and visualforce page on a single click from the page.
here is my sample xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data >
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
Please help me out.
I want to import an xml file into my lead records using the apex code and visualforce page on a single click from the page.
here is my sample xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lead-data >
<record>
<FirstName>Veera</FirstName>
<LastName>Vinnu</LastName>
<Phone>8008997654</Phone>
<Email>veerav@gmail.com</Email>
</record>
<record>
<FirstName>Beera</FirstName>
<LastName>Binnu</LastName>
<Phone>9898989898</Phone>
<Email>beeru@gmail.com</Email>
</record>
<record>
<FirstName>Ceera</FirstName>
<LastName>Cinnu</LastName>
<Phone>8989898989</Phone>
<Email>ceera@gmail.com</Email>
</record>
<record>
<FirstName>Deera</FirstName>
<LastName>Dinnu</LastName>
<Phone>7878787878</Phone>
<Email>deera@gmail.com</Email>
</record>
</lead-data>
Please help me out.
- Veerendar Aella
- November 13, 2018
- Like
- 0
- Continue reading or reply