• Adeesh maddukuri
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have custom component "CaseAsset" on case object which displays Asset values. After updating Asset object I want to refresh that component automatically to show updated values. I used below code to achieve this but feels like its not efficient way. I checked online and read about aura dependency but not sure which resource to use. Please let me know if there is any other way. Thanks in advance.
 
<aura:component implements="flexipage:availableForRecordHome,force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName" controller="CaseAssetController" access="global" >
<aura:attribute name="caseAsset" type="Case" />
<aura:attribute name="recordId" type="Id" />
<aura:handler name="init" action="{!c.fetchCs}" value="{!this}" />
<aura:dependency resource="markup://force:recordSave" type="EVENT" />
<aura:handler event="force:refreshView" action="{!c.fetchCs}" />  
  <lightning:card title="Asset With Support">
   <p class="slds-p-horizontal_small">
      <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Name}"/><br />
      <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Price}"/><br />
      <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Status}"/><br />
      <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.SerialNumber}"/><br />
   </p>
</lightning:card>
</aura:component>
Controller:
({

fetchCs : function(component,event,helper){
    helper.calltoApex(component,event);

    window.setInterval(
        $A.getCallback(function() { 
            helper.calltoApex(omponent,event);
        }), 5000
    );
},

Helper:
({
calltoApex : function(component, event) {
    var action = component.get("c.getCaseList");
    var caseId = component.get("v.recordId");

    action.setParams({
     caseId: caseId
     });

    action.setCallback(this, function(a) {
    if (a.getState() === "SUCCESS") {
        component.set("v.caseAsset", a.getReturnValue());
    } else if (a.getState() === "ERROR") {
        $A.log("Errors", a.getError());
    }
});
    $A.enqueueAction(action);


}
})

 
Hi,
 I'm trying to create a page to download multiple files as a zipfile using JSZip. I used rest api to retrive data of versiondata filed. but I'm facing problem to use that to create zip file.  Please find the code below.
  Thanks in Advance.
   
function download(){
        var zip = new JSZip();
        console.log('download function');
        var checkedSize = j$("input[name='doc_ids_group[]']:checked").size();
        console.log('checkedSize = '+checkedSize);
        
        j$("input[name='doc_ids_group[]']:checked").each(function() {
            console.log("inside each loop = "+j$(this).val());
            var id=j$(this).val();
           
             j$.ajax({url: "/services/data/v32.0/sobjects/ContentVersion/"+id+"/VersionData", headers : {
                'Authorization' : "OAuth " + sessionId,
                'Content-Type': ' application/octet-stream',
            }, async: false, success: function(result){
                
                zip.file(id, result, { base64: true }); 
               
            }});
       });
      saveAs(zip.generate({type:"blob"}), 'Download.zip', false);
                            }

 
Hi,
 
I have <apex:selectRadio> tag in my VisualForce page with  two radio buttons in it. 
I need to pass the value of the selected radio button to a JavaScript function to carry out further functionality.
Here is what I am trying to do:

// partial code from Controller

public List<SelectOption> getStateCountry() {
        List<SelectOption> nameCode= new List<SelectOption>(); 
        nameCode.add(new SelectOption('state','state')); 
        nameCode.add(new SelectOption('Country','Country')); 
      
        return nameCode; 
    }

 public String getNameCodeValue() {
        return nameCodeValue;
    }                 
    public void setNameCodeValue(String nameCodeValue) { this.nameCodeValue = nameCodeValue; }
  
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// partial code from VisualForce page
<script> 
  function testFunction(radval) 
    {
      alert('in Testfunction  : '+ radval);
  
    }
 </script> 

      <apex:form >
                 <apex:selectRadio id="nameCodeID" value="{!nameCodeValue}" onchange="testFunction('{!nameCodeValue}')" >
                <apex:selectOptions value="{!nameCode}"/>
            </apex:selectRadio>
   </apex:form >

   ============

  Alert says:  "in Testfunction  : undefined"

  Am I going in the right direction, please help.

  Thanks