• Srt
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 4
    Replies
Hi Devs,

I want to run the CURL in batch and get the data from salesforce on daily basis. 
I am facing two issues here:
1. My access token is getting changed everytime, so how can I write a program using Java or libcurl or C(I am new to this) so i can validate if access token is still valid and if not valid I will authenticate again and get access token populate it and login.
2. Once I login into salesforce, How can I use the same Java or c or libcurl to execute the CURL command and get data from salesforce.

Any links or examples are appreciated.
  • May 04, 2018
  • Like
  • 0
Hi Devs,

I have two objects which are not related to each other, Let them be Object A and Object B.
When I insert an Object A successfully , I need to update a feild called 'Result' on Object B saying successful.

The code is bulkified and I am using a list to insert Object A, How can I update the records in B saying successful based on the Database.upsertResult(or any otherway) since both the objects are not related???

Thanks in Advance :)
  • March 19, 2018
  • Like
  • 0
Component:

 

<aura:component controller="SBQ_test"

  implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
 

  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />  

</aura:component>
 

Controller:


({

  doInit : function(component, event, helper) {

 

 var action = component.get("c.doWork");

 action.setParams({

  "recId": component.get("v.recordId")

          });

 // Configure response handler

 action.setCallback(this, function(response) {

     var state = response.getState();

     if(state === "SUCCESS") {

     } else {

         console.log('Problem getting account, response state: ' + state);

     }

 });

 $A.enqueueAction(action);

 $A.get("e.force:closeQuickAction").fire();

 $A.get("e.force:refreshView").fire();

 },





Relevant Class:
 

public class SBQ_test {

  public void doWork(ID recId) {

      //perform SOME action here ON object

     try{

          update oject;
      }

  }
}

I am getting error Unknown Controller Action doWork?? Why? Pls help
  • February 19, 2018
  • Like
  • 0
<apex:page standardcontroller="Mycustomobject" extensions="dosomework">
<apex:form>
<apex:commandbutton action="{!dosomework}" value="GO!"/>
</apex:form>
</apex:page>

This is my Skeltal Code. when i try to save it I am getting error like - Can not find Mycustomobject.stdcontollerdosomework
dosomework is in extension.

Why the code is checking for method in standard controller and not in extension?
  • February 15, 2018
  • Like
  • 0
Below are my codes:
 
Component:

<aura:component controller="createRecord">
    <aura:attribute name="Campitem" type="Camp_Item__c" default="{'sobjectType': 'Camp_item__C',
                                               'Name'          : '',
                                               
                                               'Description__c': ''
                              }" />
    <lightning:input label="Name" type="Text" name="Name" value="{!v.Campitem.Name}" />
    
    <lightning:input label="Description" type="text" name="desc" value="{!v.Campitem.Description__c}" />
    <lightning:button label="Create" onclick="{!c.createRec}"/> 
</aura:component>
 
Controller:

({
    
	createRec : function(component, event, helper) {
		
        //getting the candidate information
        var camp = component.get("v.Campitem");
        
             //Validation
        if($A.util.isEmpty(camp.Name) || $A.util.isUndefined(camp.Name)){
            alert('Name is Required');
            return;
        }            
        if($A.util.isEmpty(camp.Description__c) || $A.util.isUndefined(camp.Description__c)){
            alert('Desc is Required');
            return;
        }
        
        //Calling the Apex Function
        var action = component.get("c.createCampRec");
        console.log(camp);
        //Setting the Apex Parameter
        action.setParams({
            cp : camp
        });
       
       

        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            
            //check if result is successfull
            if(state == "SUCCESS"){
                //Reset Form
               var ncamp = {'sobjectType': 'Camp_item__C',
                                               'Name'          : '',                                             
                                               'Description__c': ''
                                               
                              }
                component.set({"v.Campitem": ncamp });
                alert('Record is Created Successfully');
            } else if(state == "ERROR"){
                alert('Error in calling server side action');
            }
        });
        
		//adds the server-side action to the queue      
  $A.enqueueAction(action);  
       
	}
})
 
Apex class:

public with sharing class createRecord {
 
    @AuraEnabled
    public static void createCampRec(Camp_item__c cp )
        
    {
        try{
            System.debug('Check '+cp);
            
            if(cp != null){
                insert cp;
            }
            
        } catch (Exception ex){
            
        }
        
 }
}

When I click on create , The record is getting inserted, but I am getting error as below:

This page has an error. You might just need to refresh it.
Error in $A.getCallback() [key.indexOf is not a function]
Callback failed: apex://createRecord/ACTION$createCampRec
Failing descriptor: {c:Camp1}

Please help
  • January 10, 2018
  • Like
  • 0
Application:

<aura:application >
<c:Check/>
</aura:application>
Component:

<aura:component controller="OpportunityView">    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Opplist" type="object" />
    <p> Below is the list off accounts </p>
    <aura:iteration items="{!v.Opplist}" var="a">        
        <li><ui:outputText Value ="{!a.name}"/> 
        </li>
    </aura:iteration>
</aura:component>
Controller:

({
	doInit : function(component, event, helper) {
		helper.showcontact(component);
        
	}
})
 
Helper: 

({
	showcontact : function(component) {		
        var comp = component.get("c.getOpportunities")
        comp.setCallback(this,function(a){
            component.set("v.Opplist", a.getReturnValue());
        });
        $A.enqueueAction(comp);
	}
})
 
Apex Controller: (OpportunityView.apxc)

public class OpportunityView {
    
    @auraenabled
    Public static list<Opportunity> getOpportunities()
    {
        
        return [ select ID,Name from Opportunity];
    }

}

 
  • January 05, 2018
  • Like
  • 0
 list<Account> ACC = [select id,  (select ID, Name from Contacts) from Account];

From the above statement how to retrive and assign contact name to a Apex variable?
 
  • November 28, 2017
  • Like
  • 0
I am new to VF and Apex coding and I tried to display 'Hai + text i have entered' in an Visualforce page.
The below code works fine

VF code:

<apex:page controller="disptxt3">
  <apex:form id="form">
  <apex:pageBlock >
  <apex:pageBlockSection >
  <apex:inputtext value="{!textdata}" label="Enter your text"  />
  <apex:outputText value="{!textdatam}" rendered="{!c}" label="Value you entered " />
  </apex:pageBlockSection>
  </apex:pageBlock>  
  </apex:form>
</apex:page>

Class:

public with sharing class disptxt3 {
public string textdata{get;set;}
public boolean c;
public boolean getc()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
return c;}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}

But below doesnot work: Output box not at all displayed
Class:

public with sharing class disptxt3 {
public string textdata{get;
                       set;}
public boolean c;
public disptxt3()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
}
public boolean getc()
{
return c;
}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}
and this too doesnot work; Output box not displaying at all
Class:

public with sharing class disptxt3 {
public string textdata{get;
                       set;}
public boolean c;
public void Setc()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
}
public boolean getc()
{
return c;
}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}

Could you help me figure out why the other ways are not working? Please explain in detail ?
  • November 03, 2017
  • Like
  • 0
<apex:page standardcontroller="Mycustomobject" extensions="dosomework">
<apex:form>
<apex:commandbutton action="{!dosomework}" value="GO!"/>
</apex:form>
</apex:page>

This is my Skeltal Code. when i try to save it I am getting error like - Can not find Mycustomobject.stdcontollerdosomework
dosomework is in extension.

Why the code is checking for method in standard controller and not in extension?
  • February 15, 2018
  • Like
  • 0
Below are my codes:
 
Component:

<aura:component controller="createRecord">
    <aura:attribute name="Campitem" type="Camp_Item__c" default="{'sobjectType': 'Camp_item__C',
                                               'Name'          : '',
                                               
                                               'Description__c': ''
                              }" />
    <lightning:input label="Name" type="Text" name="Name" value="{!v.Campitem.Name}" />
    
    <lightning:input label="Description" type="text" name="desc" value="{!v.Campitem.Description__c}" />
    <lightning:button label="Create" onclick="{!c.createRec}"/> 
</aura:component>
 
Controller:

({
    
	createRec : function(component, event, helper) {
		
        //getting the candidate information
        var camp = component.get("v.Campitem");
        
             //Validation
        if($A.util.isEmpty(camp.Name) || $A.util.isUndefined(camp.Name)){
            alert('Name is Required');
            return;
        }            
        if($A.util.isEmpty(camp.Description__c) || $A.util.isUndefined(camp.Description__c)){
            alert('Desc is Required');
            return;
        }
        
        //Calling the Apex Function
        var action = component.get("c.createCampRec");
        console.log(camp);
        //Setting the Apex Parameter
        action.setParams({
            cp : camp
        });
       
       

        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            
            //check if result is successfull
            if(state == "SUCCESS"){
                //Reset Form
               var ncamp = {'sobjectType': 'Camp_item__C',
                                               'Name'          : '',                                             
                                               'Description__c': ''
                                               
                              }
                component.set({"v.Campitem": ncamp });
                alert('Record is Created Successfully');
            } else if(state == "ERROR"){
                alert('Error in calling server side action');
            }
        });
        
		//adds the server-side action to the queue      
  $A.enqueueAction(action);  
       
	}
})
 
Apex class:

public with sharing class createRecord {
 
    @AuraEnabled
    public static void createCampRec(Camp_item__c cp )
        
    {
        try{
            System.debug('Check '+cp);
            
            if(cp != null){
                insert cp;
            }
            
        } catch (Exception ex){
            
        }
        
 }
}

When I click on create , The record is getting inserted, but I am getting error as below:

This page has an error. You might just need to refresh it.
Error in $A.getCallback() [key.indexOf is not a function]
Callback failed: apex://createRecord/ACTION$createCampRec
Failing descriptor: {c:Camp1}

Please help
  • January 10, 2018
  • Like
  • 0
 list<Account> ACC = [select id,  (select ID, Name from Contacts) from Account];

From the above statement how to retrive and assign contact name to a Apex variable?
 
  • November 28, 2017
  • Like
  • 0
I am new to VF and Apex coding and I tried to display 'Hai + text i have entered' in an Visualforce page.
The below code works fine

VF code:

<apex:page controller="disptxt3">
  <apex:form id="form">
  <apex:pageBlock >
  <apex:pageBlockSection >
  <apex:inputtext value="{!textdata}" label="Enter your text"  />
  <apex:outputText value="{!textdatam}" rendered="{!c}" label="Value you entered " />
  </apex:pageBlockSection>
  </apex:pageBlock>  
  </apex:form>
</apex:page>

Class:

public with sharing class disptxt3 {
public string textdata{get;set;}
public boolean c;
public boolean getc()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
return c;}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}

But below doesnot work: Output box not at all displayed
Class:

public with sharing class disptxt3 {
public string textdata{get;
                       set;}
public boolean c;
public disptxt3()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
}
public boolean getc()
{
return c;
}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}
and this too doesnot work; Output box not displaying at all
Class:

public with sharing class disptxt3 {
public string textdata{get;
                       set;}
public boolean c;
public void Setc()
{
{if(textdata == null) 
       c = false; 
  else c = true;
  }
}
public boolean getc()
{
return c;
}
public string gettextdatam()
{
string t = 'Hai ' + textdata;
return t;
}
}

Could you help me figure out why the other ways are not working? Please explain in detail ?
  • November 03, 2017
  • Like
  • 0