• Aakanksha Singh 11
  • NEWBIE
  • 39 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 15
    Replies
Hello All,

I would like to discuss that each time I deal with sending request, I get stuck when it comes to set JSON body. Please refer to the screenshot below:

https://www.awesomescreenshot.com/image/2964112/71bc95cdc52fa43c29d4ba2f96d8a256

I've also posted an idea regarding this on success community. Please refer to the link below: 
https://success.salesforce.com/ideaView?id=0873A000000lHV3QAM
If there is a work around regarding this, please tell me.

Thanks and Regards
Aakanksha Singh
Hello Everyone,

I'm currently working on PayU payment gateway. I implemented it through rest api in apex, it is thorwing syntax error, as we have to send JSON body.
So, I tried to send request through jquery, bt I'm facing issue while redirecting. Please refer to the code below.
 
<script>
                function placeOrderPayU(){
                        
                        $.ajax('https://secure.snd.payu.com/api/v2_1/orders',{
                          type: 'POST',                                          
                          data: $.parseJSON('{"notifyUrl":"/apex/orderconfirm","customerIp":"203.122.41.218","extOrderId":'+'"'+Math.floor((Math.random()*1000)+1)+'"'+',"merchantposId":"300746","description":"des","currencyCode":"PLN","totalAmount":"4793.34","buyer":{"email":"test@wk.com","phone":"34454545","firstName":"test","lastName":"test","language":"en"},"settings":{"invoiceDisabled":"true"},"products":[{"name":"Camera","unitPrice":"1368.3400","quantity":"1"},{"name":"Jeans","unitPrice":"3425.0000","quantity":"1"}]}'),
                          crossdomain:'true',                      
                          dataType: 'jsonp',                          
                          success: function(response){
                              var res =  response["redirectUri"];
                              alert(res);
                          },
                          beforeSend: function (xhr,settings) {
                              
                              xhr.setRequestHeader('Content-Type','application/json');
                              xhr.setRequestHeader('Accept','*/*');
                              xhr.setRequestHeader('Authorization','Bearer <your token>');
                              xhr.setRequestHeader('Accept-Encoding','gzip');
                              xhr.setRequestHeader('Access-Control-Allow-Headers','*');
                              xhr.setRequestHeader('Access-Control-Allow-Origin','*');
                              xhr.setRequestHeader("Access-Control-Allow-Methods", "POST");
                              xhr.setRequestHeader('Access-Control-Request-Headers','origin,Authorization,Content-Type,Accept');
                          },
                        })
                }
            </script>

Code for generating access token is working fine.
<!--Controller-->
public with sharing class payuconfig {
    public string str{get;set;}
    public void click(){
        try{
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://secure.snd.payu.com/pl/standard/user/oauth/authorize');
            req.setMethod('POST');            
            req.setHeader('Content-Type','application/x-www-form-urlencoded');            
         
 req.setBody('grant_type=client_credentials&client_id=300746&client_secret=2ee86a66e5d97e3fadc400c9f19b065d');            
            
            Http http = new Http();
            HTTPresponse res= http.send(req);
            str = res.getBody();
            
            system.debug(str);
            
        }catch(exception e){
            system.debug(e);
        }
    }
}

<!-- Visualforce Page -->
<apex:page controller="payuconfig" standardstylesheets="false" applyHtmlTag="false" applybodytag="false" cache="false" showheader="false" doctype="html-5.0" title="Payu">
  <apex:form >
      <apex:outputPanel id="main">      
          {!str}
      </apex:outputPanel>      
      <apex:commandButton value="Click" action="{!click}" rerender="main"/>      
  </apex:form>
</apex:page>​

Please respond.
Thanx in advance
Regards
Aakanksha Singh 


 
Hello Everyone,

I'm Integrating braitree payment gateway in salesfore using REST API. But I'm not getting the desired result. Please tell me what is missing in my code which is mentioned below:
 
<!-- Visualforce Page -->
<apex:page controller="braintreeConfig" standardstylesheets="false" applyHtmlTag="false" applybodytag="false" cache="false" showheader="false" doctype="html-5.0" title="Braintree">
  <apex:form >
      <apex:outputPanel id="main">      
          {!str}
      </apex:outputPanel>
      <apex:commandButton value="Click" action="{!click}" rerender="main" oncomplete="myfunc()"/>      
  </apex:form>  
</apex:page>


<!-- Controller -->
public with sharing class braintreeConfig{

    public string str{get;set;} 
    public void click(){
        try{
        
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://api.sandbox.braintreegateway.com:443/merchants/qhbgvbfxxsqdrbtj/client_token/?version=2');
            req.setMethod('POST');
            
            
            map<string,string> mp = new map<string,string>();
            mp.put('[environment:Braintree\\Configuration:private]', 'sandbox');
            mp.put('[merchantId:Braintree\\Configuration:private]', 'qhbgvbfxxsqdrbtj');
            mp.put('[publicKey:Braintree\\Configuration:private]', '52nztrwwvp8zvqg8');
            mp.put('[privateKey:Braintree\\Configuration:private]', 'f17db5318738459ca0278906181d5aa8');
            mp.put('[_clientId:Braintree\\Configuration:private]', '');
            mp.put('[_clientSecret:Braintree\\Configuration:private]', '');
            mp.put('[_accessToken:Braintree\\Configuration:private]', '');
            mp.put('[_proxyHost:Braintree\\Configuration:private]', '');
            mp.put('[_proxyPort:Braintree\\Configuration:private]', '');
            mp.put('[_proxyType:Braintree\\Configuration:private]', '');
            mp.put('[_proxyUser:Braintree\\Configuration:private]', '');
            mp.put('[_proxyPassword:Braintree\\Configuration:private]', '');
            mp.put('[timeout:Braintree\\Configuration:private]', '60');
            mp.put('[acceptGzipEncoding:Braintree\\Configuration:private]', '1');
            mp.put('[_useClientCredentials:Braintree\\Http:private]', '');
            
            req.setBody(JSON.serialize(mp));
            
            Http http = new Http();
            HTTPresponse res= http.send(req);
            str = res.getBody();
            
        }catch(exception e){
            system.debug(e);
        }
    }   
    
}

I'm getting the response mentioned in screenshot.
https://qsnapnet.com/snaps/o1bn133wd5z5mi 

Please Help me out with this.

Thanks In Advance
Aakanksha Singh 
 
Hello everyone,

I'm facing issue in lightning component in regard with jquery. It is working fine in lightning experience, but in salesforce1 it is throwing following error(please refer to the screenshot):
https://www.awesomescreenshot.com/image/2538053/828e04a4acf23e355333f5035a3fc968

Here is my code:
<!----Component---->
<!----jquery.min.js (version 2.2.4)---->
<aura:component implements="force:appHostable">
    <ltng:require scripts="{!$Resource.jquery}" afterScriptsLoaded="{!c.scriptsLoaded}"/>
</aura:component>



<!----Controller---->
({
	scriptsLoaded : function(component, event, helper) {
            alert("working");
        },
})

Please respond

Regards
Aakanksha Singh
Hello Everyone,

I'm working on creating dynamic components, It is working succesfully just for once, and not afterwards. I'm posting my code as well, Please help me with this:
<!--DynamicModalBox(Component)-->
<aura:component >
    <c:DynamicModalBoxButton/>
</aura:component>
 
<!--DynamicModalBoxButton(Component)-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +'/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:registerEvent name="openPopup" type="c:DynamicModalBoxEvent"/>
    <aura:handler name="RemoveComponent" action="{!c.removeComponent}" event="c:RemoveComponent"/>
	<div class="static">
    	<button class="slds-button slds-button--neutral" onclick="{!c.getCompnent}">Open Modal</button>
    
        <div aura:id="cmpBody">
            {!v.body}
        </div>
    </div>
</aura:component>


<!--Controller-->
({
	getCompnent: function(cmp,event) {
        //var articleId = cmp.get("v.ArticleId");
        var cmpBody=cmp.find("cmpBody");     
        $A.createComponent(
            "c:DynamicModalBoxPopup",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    body.push(newcomponent);
                    cmp.set("v.body", body);                    
                }
            }            
        );
        var compEvent = cmp.getEvent("openPopup");
       	compEvent.fire();
    },
    removeComponent:function(cmp,event){
        var cmpBody=cmp.find("cmpBody");
        var comp = event.getParam("comp");
		//alert(comp.toString());
        $A.createComponent(
            comp.toString(),{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    cmpBody.set("v.body",[]);
                }
            }
        );
    },
})
 
<!--DynamicModalBoxPopup(Component)-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +'/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
    <aura:handler name="openPopup" action="{!c.initialize}" event="c:DynamicModalBoxEvent"/>
    <aura:registerEvent name="RemoveComponent" type="c:RemoveComponent"/>
	<div class="wk_static">
        <div role="dialog" tabindex="-1" aura:id="Modalbox" aria-labelledby="header43" class="slds-modal ">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <button class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.removeComponent}">
                        <span>
                            <c:SVG class="slds-button__icon slds-button__icon--large" xlinkHref="/resource/SLDS/assets/icons/action-sprite/svg/symbols.svg#close" />
                            <span class="slds-assistive-text">Close</span>
                        </span>                 
                    </button>
                    <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div>
                        <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                        quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p>
                        <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
                        nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Close</button>
                    <!--<button class="slds-button slds-button-neutral slds-button-brand">Save</button>-->
                </div>
            </div>
        </div>
        <div class="slds-backdrop " aura:id="MB-Back"></div>
        
    </div>
</aura:component>




<!--Controller-->
({
	initialize:function(cmp,event){        
        var cmpTarget = cmp.find('Modalbox');
       	var cmpBack = cmp.find('MB-Back');
        $A.util.addClass(cmpTarget, 'slds-fade-in-open');
        $A.util.addClass(cmpBack, 'slds-backdrop--open'); 
    },
    removeComponent:function(component, event, helper){
        var compEvent = component.getEvent("RemoveComponent");
        compEvent.setParams({
        	"comp" : component
        });
	    compEvent.fire();
    }
})
 
<!--Events Used-->

<!--RemoveComponent-->
<aura:event type="COMPONENT" description="Event template" >
    <aura:attribute name="comp" type="Aura.Component"/>
</aura:event>

<!--DynamicModalBoxEvent-->
<aura:event type="COMPONENT" description="Event template" />

Regards
Aakanksha Singh
Hello Everyone,

Greetings!!

I want know how SOQL subquery can be written in  REST explorer on workBench, for example, I have to fetch accounts and related contacts with the following SOQL query:

-> SELECT Id,Name,(SELECT Id,Name FROM Contacts) FROM Account

How this query could be written IB REST Explorer?

Please respond. Thanks in advance.

Regards
Aakanksha Singh
Hello Everyone,

I want to know the possible ways through which we can fetch more than 50k/1million records through apex class in salesforce.

Please respond.

Thanks in advance.

Rregards
Aakanksha Singh
Hello Everyone,

I'm trying to assing a value of a variable from an Batch class to a static variable in apex class. When I debug it though the developer console, I observe that the value is assigned succussfully, but when I access it through class I don't get any value i.e null. You can view my code below:

<pre>
//----Batch Class----//
global with sharing class fetchAccountBatch implements Database.Batchable<sObject>, Database.stateful{
    
    public list<account> acc= new list<account>();
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        string query = 'Select Id,Name from Account';
        return Database.getQueryLocator(query);
        
    }
    global void execute(Database.BatchableContext BC, list<Account> scope){
    
        for(account a: scope){
            acc.add(a);
        }
        
    }
    global void finish(Database.BatchableContext BC){
        
        system.debug(acc);
        
        fetchAccountClass.acc.addAll(acc);
        
        system.debug(fetchAccountClass.acc);
    
    }
    
}
</pre>

<pre>
//----Scheduled Class----//
global with sharing class fetchAccountSchedule implements Schedulable{     
     
     global void execute(SchedulableContext sc) {

        fetchAccountBatch bc = new fetchAccountBatch();
        database.executeBatch(bc,2000);
        system.debug(fetchAccountClass.acc);
    }
    
}
</pre>

<pre>
//----Apex Class----//
global with sharing class fetchAccountClass {   
    
    global static list<account> acc{get{
        
        if(acc==null)
            acc = new list<account>();
            
        return acc; 
    }set;}
    
    public void fetchAccount(){
        
        DateTime dt = system.now().addSeconds(1);
        integer h = integer.valueOf(dt.hour());
        integer m = integer.valueOf(dt.minute());
        integer s = integer.valueOf(dt.second());
        
        
        try{
            CronTrigger cr = [SELECT Id, CronJobDetail.Name FROM CronTrigger where CronJobDetail.Name ='TestJob'];
            if(cr!=null && cr!= new crontrigger()){
                     system.abortJob(cr.Id);
                 }
        }catch(exception e){}
        
        try{
            string cronExp = s+' '+m+' '+h+' ? * * *';
            system.schedule('TestJob',cronExp,new fetchAccountSchedule());            
            
        }catch(Exception e){
            
            apexpages.addMessages(e);
                    
        }
    }
}
</pre>

<pre>
<!--Visualforce Page-->
<apex:page controller="fetchAccountClass">

    <apex:form >
        
        <apex:sectionHeader Title="Account" subtitle="List View"/>
        
        <apex:pageblock title="Account List" >
            <apex:pageblockbuttons>
                <apex:commandButton value="Get Data" action="{!fetchAccount}" rerender="AccountTable"/>
            </apex:pageblockbuttons>
        
            <apex:pageMessages/>
            <apex:pageblocktable value="{!acc}" var="key" id="AccountTable">
            
                <apex:column value="{!key.Id}"/>
                <apex:column value="{!key.name}"/>
            
            </apex:pageblocktable>
        </apex:pageblock>
    </apex:form>

</apex:page>

</pre>

Please Respond.

Thanks in advance.

Regards
Aakanksha Singh
 
Hello Everyone,

I'm trying to use force:navigateToComponent, but its not working. Here is my code:
<pre>
({
    NavigatetoComp : function(component, event, helper) {
        
        console.log('Enter Here');
        var evt = $A.get("e.force:navigateToComponent");
        console.log('evt'+evt);
        evt.setParams({
            componentDef: "c:MyComponent2",
            //componentAttributes :{ }
        });
       
        evt.fire();
    }
})
</pre>

It throws following error:
User-added image

Can any body tell why is it so?

Thanks In Advance
Aakanksha Singh
Hello everyone,

I'm trying to run a Schedule job in which runs when its a day before contact's birthday and reminder is sent only to the current user(System admin). 

Can anybody help?

Thank You
Hello everyone,

Could you help me with applying jquery/javascript in tabs designed through lightning design system in lightning component.

link: https://www.lightningdesignsystem.com/components/tabs/#flavor-scoped

Thank you
Aakanksha Singh
Hello Everyone,

I'm currently working on PayU payment gateway. I implemented it through rest api in apex, it is thorwing syntax error, as we have to send JSON body.
So, I tried to send request through jquery, bt I'm facing issue while redirecting. Please refer to the code below.
 
<script>
                function placeOrderPayU(){
                        
                        $.ajax('https://secure.snd.payu.com/api/v2_1/orders',{
                          type: 'POST',                                          
                          data: $.parseJSON('{"notifyUrl":"/apex/orderconfirm","customerIp":"203.122.41.218","extOrderId":'+'"'+Math.floor((Math.random()*1000)+1)+'"'+',"merchantposId":"300746","description":"des","currencyCode":"PLN","totalAmount":"4793.34","buyer":{"email":"test@wk.com","phone":"34454545","firstName":"test","lastName":"test","language":"en"},"settings":{"invoiceDisabled":"true"},"products":[{"name":"Camera","unitPrice":"1368.3400","quantity":"1"},{"name":"Jeans","unitPrice":"3425.0000","quantity":"1"}]}'),
                          crossdomain:'true',                      
                          dataType: 'jsonp',                          
                          success: function(response){
                              var res =  response["redirectUri"];
                              alert(res);
                          },
                          beforeSend: function (xhr,settings) {
                              
                              xhr.setRequestHeader('Content-Type','application/json');
                              xhr.setRequestHeader('Accept','*/*');
                              xhr.setRequestHeader('Authorization','Bearer <your token>');
                              xhr.setRequestHeader('Accept-Encoding','gzip');
                              xhr.setRequestHeader('Access-Control-Allow-Headers','*');
                              xhr.setRequestHeader('Access-Control-Allow-Origin','*');
                              xhr.setRequestHeader("Access-Control-Allow-Methods", "POST");
                              xhr.setRequestHeader('Access-Control-Request-Headers','origin,Authorization,Content-Type,Accept');
                          },
                        })
                }
            </script>

Code for generating access token is working fine.
<!--Controller-->
public with sharing class payuconfig {
    public string str{get;set;}
    public void click(){
        try{
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://secure.snd.payu.com/pl/standard/user/oauth/authorize');
            req.setMethod('POST');            
            req.setHeader('Content-Type','application/x-www-form-urlencoded');            
         
 req.setBody('grant_type=client_credentials&client_id=300746&client_secret=2ee86a66e5d97e3fadc400c9f19b065d');            
            
            Http http = new Http();
            HTTPresponse res= http.send(req);
            str = res.getBody();
            
            system.debug(str);
            
        }catch(exception e){
            system.debug(e);
        }
    }
}

<!-- Visualforce Page -->
<apex:page controller="payuconfig" standardstylesheets="false" applyHtmlTag="false" applybodytag="false" cache="false" showheader="false" doctype="html-5.0" title="Payu">
  <apex:form >
      <apex:outputPanel id="main">      
          {!str}
      </apex:outputPanel>      
      <apex:commandButton value="Click" action="{!click}" rerender="main"/>      
  </apex:form>
</apex:page>​

Please respond.
Thanx in advance
Regards
Aakanksha Singh 


 
I wrote a trigger to prevent task creation if customer Account is blocked.

This is my code,

trigger EventBlocked on Event (Before insert,after update) {
  
    list<Contact> clist =new list<Contact>();
    string Cname;
    
        for (Event t : Trigger.new) {
        
            if (t.WhoId !=Null) {
                
                clist= [select ID, Account_name__C, Account.Lock_record__C from Contact where 
                ID=:t.WhoId and Account.Lock_record__C=True]; 
                
            }
            
            IF(Clist.size()>0)
            {
            T.adderror('You Cant create a Event under the blocked Contact');
            }
            }
            }


How to write a test class for this trigger to improve the code coverage?
Hello Everyone,

I'm working on creating dynamic components, It is working succesfully just for once, and not afterwards. I'm posting my code as well, Please help me with this:
<!--DynamicModalBox(Component)-->
<aura:component >
    <c:DynamicModalBoxButton/>
</aura:component>
 
<!--DynamicModalBoxButton(Component)-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +'/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:registerEvent name="openPopup" type="c:DynamicModalBoxEvent"/>
    <aura:handler name="RemoveComponent" action="{!c.removeComponent}" event="c:RemoveComponent"/>
	<div class="static">
    	<button class="slds-button slds-button--neutral" onclick="{!c.getCompnent}">Open Modal</button>
    
        <div aura:id="cmpBody">
            {!v.body}
        </div>
    </div>
</aura:component>


<!--Controller-->
({
	getCompnent: function(cmp,event) {
        //var articleId = cmp.get("v.ArticleId");
        var cmpBody=cmp.find("cmpBody");     
        $A.createComponent(
            "c:DynamicModalBoxPopup",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    body.push(newcomponent);
                    cmp.set("v.body", body);                    
                }
            }            
        );
        var compEvent = cmp.getEvent("openPopup");
       	compEvent.fire();
    },
    removeComponent:function(cmp,event){
        var cmpBody=cmp.find("cmpBody");
        var comp = event.getParam("comp");
		//alert(comp.toString());
        $A.createComponent(
            comp.toString(),{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    cmpBody.set("v.body",[]);
                }
            }
        );
    },
})
 
<!--DynamicModalBoxPopup(Component)-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +'/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
    <aura:handler name="openPopup" action="{!c.initialize}" event="c:DynamicModalBoxEvent"/>
    <aura:registerEvent name="RemoveComponent" type="c:RemoveComponent"/>
	<div class="wk_static">
        <div role="dialog" tabindex="-1" aura:id="Modalbox" aria-labelledby="header43" class="slds-modal ">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <button class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.removeComponent}">
                        <span>
                            <c:SVG class="slds-button__icon slds-button__icon--large" xlinkHref="/resource/SLDS/assets/icons/action-sprite/svg/symbols.svg#close" />
                            <span class="slds-assistive-text">Close</span>
                        </span>                 
                    </button>
                    <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div>
                        <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                        quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p>
                        <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
                        nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Close</button>
                    <!--<button class="slds-button slds-button-neutral slds-button-brand">Save</button>-->
                </div>
            </div>
        </div>
        <div class="slds-backdrop " aura:id="MB-Back"></div>
        
    </div>
</aura:component>




<!--Controller-->
({
	initialize:function(cmp,event){        
        var cmpTarget = cmp.find('Modalbox');
       	var cmpBack = cmp.find('MB-Back');
        $A.util.addClass(cmpTarget, 'slds-fade-in-open');
        $A.util.addClass(cmpBack, 'slds-backdrop--open'); 
    },
    removeComponent:function(component, event, helper){
        var compEvent = component.getEvent("RemoveComponent");
        compEvent.setParams({
        	"comp" : component
        });
	    compEvent.fire();
    }
})
 
<!--Events Used-->

<!--RemoveComponent-->
<aura:event type="COMPONENT" description="Event template" >
    <aura:attribute name="comp" type="Aura.Component"/>
</aura:event>

<!--DynamicModalBoxEvent-->
<aura:event type="COMPONENT" description="Event template" />

Regards
Aakanksha Singh
Hello Everyone,

Greetings!!

I want know how SOQL subquery can be written in  REST explorer on workBench, for example, I have to fetch accounts and related contacts with the following SOQL query:

-> SELECT Id,Name,(SELECT Id,Name FROM Contacts) FROM Account

How this query could be written IB REST Explorer?

Please respond. Thanks in advance.

Regards
Aakanksha Singh
Hello Everyone,

I want to know the possible ways through which we can fetch more than 50k/1million records through apex class in salesforce.

Please respond.

Thanks in advance.

Rregards
Aakanksha Singh
Hello Everyone,

I'm trying to assing a value of a variable from an Batch class to a static variable in apex class. When I debug it though the developer console, I observe that the value is assigned succussfully, but when I access it through class I don't get any value i.e null. You can view my code below:

<pre>
//----Batch Class----//
global with sharing class fetchAccountBatch implements Database.Batchable<sObject>, Database.stateful{
    
    public list<account> acc= new list<account>();
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        string query = 'Select Id,Name from Account';
        return Database.getQueryLocator(query);
        
    }
    global void execute(Database.BatchableContext BC, list<Account> scope){
    
        for(account a: scope){
            acc.add(a);
        }
        
    }
    global void finish(Database.BatchableContext BC){
        
        system.debug(acc);
        
        fetchAccountClass.acc.addAll(acc);
        
        system.debug(fetchAccountClass.acc);
    
    }
    
}
</pre>

<pre>
//----Scheduled Class----//
global with sharing class fetchAccountSchedule implements Schedulable{     
     
     global void execute(SchedulableContext sc) {

        fetchAccountBatch bc = new fetchAccountBatch();
        database.executeBatch(bc,2000);
        system.debug(fetchAccountClass.acc);
    }
    
}
</pre>

<pre>
//----Apex Class----//
global with sharing class fetchAccountClass {   
    
    global static list<account> acc{get{
        
        if(acc==null)
            acc = new list<account>();
            
        return acc; 
    }set;}
    
    public void fetchAccount(){
        
        DateTime dt = system.now().addSeconds(1);
        integer h = integer.valueOf(dt.hour());
        integer m = integer.valueOf(dt.minute());
        integer s = integer.valueOf(dt.second());
        
        
        try{
            CronTrigger cr = [SELECT Id, CronJobDetail.Name FROM CronTrigger where CronJobDetail.Name ='TestJob'];
            if(cr!=null && cr!= new crontrigger()){
                     system.abortJob(cr.Id);
                 }
        }catch(exception e){}
        
        try{
            string cronExp = s+' '+m+' '+h+' ? * * *';
            system.schedule('TestJob',cronExp,new fetchAccountSchedule());            
            
        }catch(Exception e){
            
            apexpages.addMessages(e);
                    
        }
    }
}
</pre>

<pre>
<!--Visualforce Page-->
<apex:page controller="fetchAccountClass">

    <apex:form >
        
        <apex:sectionHeader Title="Account" subtitle="List View"/>
        
        <apex:pageblock title="Account List" >
            <apex:pageblockbuttons>
                <apex:commandButton value="Get Data" action="{!fetchAccount}" rerender="AccountTable"/>
            </apex:pageblockbuttons>
        
            <apex:pageMessages/>
            <apex:pageblocktable value="{!acc}" var="key" id="AccountTable">
            
                <apex:column value="{!key.Id}"/>
                <apex:column value="{!key.name}"/>
            
            </apex:pageblocktable>
        </apex:pageblock>
    </apex:form>

</apex:page>

</pre>

Please Respond.

Thanks in advance.

Regards
Aakanksha Singh
 
Hello Everyone,

I'm trying to use force:navigateToComponent, but its not working. Here is my code:
<pre>
({
    NavigatetoComp : function(component, event, helper) {
        
        console.log('Enter Here');
        var evt = $A.get("e.force:navigateToComponent");
        console.log('evt'+evt);
        evt.setParams({
            componentDef: "c:MyComponent2",
            //componentAttributes :{ }
        });
       
        evt.fire();
    }
})
</pre>

It throws following error:
User-added image

Can any body tell why is it so?

Thanks In Advance
Aakanksha Singh
Hi, 

I want to display list of accounts with contacts in lightning page. Here the code i have written. Here accounts are displaying but contacts are not display. Please help me to display the accounts with contacts.

Thank you.


 
<aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
	 
    <aura:attribute name="accounts" type="Account[]" />
    <ui:button label="click this" press="{!c.myAction}" />
    <table>
            <tr><td><b>Name</b></td><td><b>Industry</b></td></tr>

    <aura:iteration items="{!v.accounts}" var="accs1" >
        <tr>   
        <td> {!accs1.Name}  </td>
         
      <td>   {!accs1.Industry}  </td> 
      <!--   <td>   {!accs1.Contacts.lastName}  </td> -->
        </tr>     
     <tr>   <aura:iteration items="{!v.accs1.contacts}" var="con1" >
            
             <td>{!con1.lastName} </td>
            
        </aura:iteration></tr>
     </aura:iteration>                                            
        </table>
    
</aura:component>








({
	myAction : function(component, event, helper) {
		var action =component.get("c.getAllAccounts");
        console.log('The action value is: '+action);
         action.setCallback(this, function(a){ 
             
            component.set("v.accounts", a.getReturnValue());
           //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
            console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
          
        });
        $A.enqueueAction(action);
	}
})











public class accountsWithContactsClass {

@auraEnabled
public static list<account> getAllAccounts()
    {
       list<account> accs =[select id,name,phone,industry,(select lastName from contacts) from account limit 10];
      //  list<account> accs =[select id,name,phone,industry from account limit 10];
     //   return [select Id,Name from account limit 10];
     return accs;
    }
}

 

I have done the workaround for the sort line items.   The lines are sorted via a custom web service so there is no need to pop up the /oppitm/lineitemsort.jsp page.    I create the form and hidden fields dynamically and hit submit.   This pops up the jsp page.   I want to skip that and auto submit via ajax or something.    It works when I have form.submit() and the form pops up and I click the Save button.   Is there a way to replace the form.submit() and having the user click the save button.

 

I tried to use jquery ajax and ajaxSubmit, but I get an error with the error message so not sure what is wrong.   Can this be done and does anyone know how to do that part.

 

--------------------------------------------------------------------------------------------

 

So I had this originally:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}

var quoteID = '{!Quote.Id}';

//call the apex web service to get the QLIs in the desired sort order for this opp
//var result = sforce.apex.execute("customSort","MRsort",{quoteID:quoteID});   
var result = sforce.apex.execute("customSort","QLI_SortByPrdQty",{quoteID:quoteID});   

//need to post a form to /oppitm/lineitemsort.jsp because this is how SFDC
//does it but there is not direct API to do the sorting (thus the awkward workaround)
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "/oppitm/lineitemsort.jsp");

form.setAttribute("id", "sortForm");

//set the id of the request to the quote ID
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'id');
hiddenField.setAttribute("value", '{!Quote.Id}');   
form.appendChild(hiddenField);

//the name of the sorted OLI list that the JSP is expecting is "duel0"
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'duel0');
hiddenField.setAttribute("value", String(result));
form.appendChild(hiddenField);

var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'retURL');
hiddenField.setAttribute("value", '/{!Quote.Id}');
form.appendChild(hiddenField);

//set to save
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'save');
hiddenField.setAttribute("value", ' Save ');
form.appendChild(hiddenField);

//need to do this so it works in IE
document.body.appendChild(form);

//submit!!
form.submit();

 

I have been commenting out the form.submit and trying to use jquery / ajax to automate:

 

I include the jquery js scripts:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
    <script src="http://malsup.github.com/jquery.form.js"></script>

 

I tried using $.ajax where formData is the form data serialized but get the error alert with error=error. 

 

         $.ajax({
             type: "post",
             url:  "https://na14.salesforce.com/oppitm/lineitemsort.jsp",
             data: formData,
             success: function() {
                 alert('>> ajax submit successful <<');
             },
             error: function(req, status, error) {
                 alert('>> ajax submit failed: status='+ status + ' error=' + error + ' <<');
             }
         });
        

Then tried and get the error alert with error=error again.
         
         $('#sortForm').ajaxSubmit({
             success: function() {
                 alert('>> ajax submit successful <<');
             },
             error: function(req, status, error) {
                 alert('>> ajax submit failed: req='+req+' status='+ status + ' error=' + error + ' <<');
             }
         });