• hemanth tanguturi 10
  • NEWBIE
  • 24 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
I have a parent page but I can't mdify it. I need to add a modal on the parent page, for that I have a iframe on parent page from there i need to open the modal on parent page..
Here is the code..

The modal div is available in child page which need to opened as modal on parent page on load, below code is some what closer bu it is on button click and modal is opening on child page only but i need it to be open on parent page..
***just to remind i can't make changes on parent page as parent page is in managed package..
Parent Page:
<html>

<h2>AniParentPage</h2>

<!-- Trigger/Open The Modal -->
<iframe src="C:\hello\iFrame\childPage.html" id="frameid">
</html>

Child Page:
<!DOCTYPE html>
<html>
<head>
<style>
/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba

(0,0,0,0.19);
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s
}

/* Add Animation */
@-webkit-keyframes animatetop {
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1}
}

@keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
}

/* The Close Button */
.close {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    padding: 2px 16px;
    background-color: #5cb85c;
    color: white;
}

.modal-body {padding: 2px 16px;}

.modal-footer {
    padding: 2px 16px;
    background-color: #5cb85c;
    color: white;
}
</style>
</head>
<body>

<h2>Animated Modal with Header and Footer</h2>

<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>

<!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <div class="modal-header">
      <span class="close">&times;</span>
      <h2>Modal Header</h2>
    </div>
    <div class="modal-body">
      <p>Some text in the Modal Body</p>
      <p>Some other text...</p>
    </div>
    <div class="modal-footer">
      <h3>Modal Footer</h3>
    </div>
  </div>

</div>

<script>
// Get the modal
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
    modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
    
$(document).ready(function(){
         modal.style.display = "block";
    });
}
</script>

</body>
</html>



here in below image the popup is opened in child page i need it to be opened on parent page and on page load..

User-added image
Hi,

I have a issue with comma seperator in csv file download.
<apex:page controller="AnalysisController"   contentType="application/vnd.ms-excel#Analysis.csv">
<apex:outputText value="{!price}" >
this is what i am using in the vf page to print the price value. Here price is a string 6,44,567.00  as this string is having comma the out put is splitting in to different cells, like 6 in one cell 44 in other and 567.00 in other cell.
How can I over come this issue?
1) As the source of my report is from multiple Maps i am not able to download in xls
2) Tried to use format for outputtext component but here in my case the value is string
3) Tried to remove the comma using substitue but as my app supports multiple locale, people in some locale uses comma as decimal seperator hence can't remove comma.

Thanks in advance.

Hemanth
Can someone help me with the test class for upload attachment and delete attachment, Bwlow is my vf page and controller:
 
VF Page:
<tr class="rowPt10">
                                            <td class="pb18 w20 textRight bold pr10 pl10" valign="top">
                                                <apex:outputText value="Attachments"/>
                                            </td>
                                            
                                            <td class="pb18 greyText">
                                                <apex:inputFile value="{!attachment.body}" fileName="{!attachment.name}" id="file"/>
                                                <apex:commandButton value="Upload" action="{!upload}" />
                                            </td>
                                            
                                        </tr>
          								<tr class="rowPt10">
                                            <td class="pb18 greyText">
                                            <apex:inputTextarea value="{!attachment.Description}"/>
                                            </td>
          										
          								</tr>
                                        <tr class="rowPt10">
                                            
                                            <td colspan="3" class = "leftPadding" >
                                                <apex:dataTable value="{!myList}" var="attachmentRow">
                                                    <apex:column >
                                                            <apex:commandLink action="{!DeleteAttach}" value="X"
                                                                styleClass="btnSave fs8 btnXpadding GreyText left mr10 rc2"
                                                                onclick="if(!confirm('Delete this attachment?')){event.preventDefault(); return false;};">
                                                                <apex:param name="deleteAttachmentId" value="{!attachmentRow.id}" assignTo="{!deleteAttachmentId}" />
                                                            </apex:commandLink>
                                                        </apex:column>
                                                    <apex:column >
                                                            <apex:outputLink value="{!URLFOR($Action.Attachment.Download,attachmentRow.Id)}" target="$_">
                                                                {!attachmentRow.Name}
                                                            </apex:outputLink>
                                                            &nbsp;&nbsp;
                                                            <apex:outputText value="[ By {!attachmentRow.CreatedBy.Name} on {!attachmentRow.CreatedDate}]"/>
                                                    </apex:column>
                                                </apex:dataTable>
                                            </td>
                                        </tr>
                                        
                                    </table>



Controller:


public class SF_AttachmentExecSummaryController {
    public string Pid{get;set;}
    public list<attachment> myList{get; set;}
    Public string deleteAttachmentId{get;set;}
    public SF_AttachmentExecSummaryController(){
        //Pid='a0o17000002AvZvAAK';
    	Pid =ApexPages.currentPage().getParameters().get('Pid');
        system.debug('id:::::'+Pid);
        loadAttachments();
    }
    
    public attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }

  public PageReference upload() {

    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = Pid; // the record the file is attached to
    attachment.IsPrivate = true;

    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
	loadAttachments();
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
    
    public void loadAttachments(){
        myList = new list<attachment>();//h
        myList = [SELECT CreatedDate,Name,CreatedBy.Name FROM Attachment where parentid =:Pid];//h
    }
    public void DeleteAttach() {
        if (deleteAttachmentId!=null){

             Attachment attachment = [SELECT Id, OwnerId, ParentId from attachment where Id = :deleteAttachmentId];
             //MnPriceApprovalAttachment__c mnPriceApprovalAttachment = [Select Id from MnPriceApprovalAttachment__c where Id=:attachment.ParentId];
             if(userinfo.getUserId()==attachment.OwnerId) {
                try{
                delete attachment ;
                }
                catch (DMLException e) {
                    System.debug('The following exception has occurred: ' + e.getMessage());
                }
            }

             loadAttachments();
        }
    } 
}

 
Got Error  while implementing the lightning application for trailhead module "Connect to salesforce with server side controllers":
Error: Something has gone wrong. Error during init [TypeError: Cannot read property 'apply' of undefined] . Please try again.

Please help below is the Code, Pls help

CampingApp.app:
<aura:application >
	
    <ltng:require styles="{!$Resource.SLDS203 +
         '/assets/styles/salesforce-lightning-design-system.css'}"/>
    
    <div class="slds">
       
        <!-- This component is the real "app" -->
        <c:campingList />
       
    </div>
    
    
</aura:application>

CampingList.cmp:
<aura:component controller="CampingListController" >
    
    <aura:handler name="this" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{'sobjectType': 'Camping_Item__c',
                             'Price__c':0,
                             'quantity':0},
                             'Packed__c':false,
                             'Name':''}"/>
    <!--aura:attribute type="camping_item__c[]" name="items"/-->
        <aura:attribute name="items" type="Camping_Item__c[]"/>

    
    <!-- PAGE HEADER -->
    <div class="slds-page-header" role="banner">
      <div class="slds-grid">
        <div class="slds-col">
          <p class="slds-text-heading--label">Campings</p>
          <h1 class="slds-text-heading--medium">My Campings</h1>
        </div>
      </div>
    </div>
    <!-- / PAGE HEADER -->
    
    <!-- NEW Campign FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">


          
  <div aria-labelledby="CampingForm">

  <!-- BOXED AREA -->
  <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="CampingForm" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Camping
    </legend>

    <!-- CREATE NEW EXPENSE FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="campingName" label="Camping Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>
          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="Price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  required="true"/>

          </div>
      </div>

      
      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Campign"
              class="slds-button slds-button--brand"
              press="{!c.clickCreateCamping}"/>
      </div>

    </form>
    <!-- / CREATE NEW EXPENSE FORM -->

  </fieldset>
  <!-- / BOXED AREA -->

</div>
        </div>
    
    
    
    <div class="slds-col slds-col--padded slds-p-top--large">
    <aura:iteration items="{!v.items}" var="item">
      <c:campingListItem item="{!item}"/>
        </aura:iteration>
    </div>
    
    
    
</aura:component>

CampingListController.js:
({
    
    // Load expenses from Salesforce
doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state == "SUCCESS") {
            console.log("Result: " + response.getReturnValue());
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
},
    
    
    
    clickCreateCamping: function(component, event, helper) {

        // Simplistic error checking
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("campingName");
        var campname = nameField.get("v.value");
        
        if ($A.util.isEmpty(campname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        if ($A.util.isEmpty(component.find("quantity").get("v.value"))){
            validCamping = false;
            component.find("quantity").set("v.errors", [{message:"Camping Quantity can't be blank."}]);
        }
        else {
            component.find("quantity").set("v.errors", null);
        }
        if ($A.util.isEmpty(component.find("Price").get("v.value"))){
            validCamping = false;
            component.find("Price").set("v.errors", [{message:"Camping Price can't be blank."}]);
        }
        else {
            component.find("Price").set("v.errors", null);
        }
        
        

        // ... hint: more error checking here ...

        // If we pass error checking, do some real work
        if(validCamping){
            // Create the new expense
            
            var newCampignItem = Component.get("v.newItem");
            helper.createItem(component, newCampignItem);
        }
    }
})

CampingListController.aspx:
public class CampingListController {

    @auraEnabled
    Public static list<Camping_Item__c> getItems(){
        
        return [select Name, Quantity__c, Price__c, Packed__c from Camping_Item__c];
        
    }
    
    @auraEnabled
    Public static Camping_Item__c saveItem (Camping_Item__c Camping){
        
        upsert Camping;
        return Camping;
        
    }
    
}

CampingListHelper:
({
	createItem : function(component, campingItem) {
		var action = component.get("c.saveItem");
        action.setParams({"Camping", campignItem});
                          
                          action.setCallback(this, function(response){
                          var state = response.getState();
        				if (component.isValid() && state === "SUCCESS") {
            				var items = component.get("v.Items");
            				expenses.push(response.getReturnValue());
            				component.set("v.Items", items);
                         }
                         });
                          $A.enqueueAction(action);
        
	}
})



 
Hi All,

with below code I have completed the challenge thanks!!...When I tried to add this componet to Application and tried to check the UI part..I got below error, Can some one please let me know what the mistake is???

Something has gone wrong. [NoErrorObjectAvailable] Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 991118890-131685 (-1741317831) . Please try again.

APP:

<aura:application >
    <c:campingListItem />
</aura:application>


COMPONENT:

<aura:component >

    <aura:attribute name="item" type="Camping_Item__c" required="true"/>
    <ui:outputText value="{!v.item}"/>
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    <ui:outputCurrency value="{!v.item.Price__c}"/>
    <ui:outputNumber value="{!v.item.Quantity__c}"/>
    
    <ui:button label="packed!" press="{!c.packItem}" > 
    </ui:button>
</aura:component>


CONTROLLER:
({
    packItem: function(component, event, helper) {
        var a = component.get("v.item",true);
       
        a.Packed__c = true;
        component.set("v.item",a);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
    }
})


Thanks
Hi,

I have a issue with comma seperator in csv file download.
<apex:page controller="AnalysisController"   contentType="application/vnd.ms-excel#Analysis.csv">
<apex:outputText value="{!price}" >
this is what i am using in the vf page to print the price value. Here price is a string 6,44,567.00  as this string is having comma the out put is splitting in to different cells, like 6 in one cell 44 in other and 567.00 in other cell.
How can I over come this issue?
1) As the source of my report is from multiple Maps i am not able to download in xls
2) Tried to use format for outputtext component but here in my case the value is string
3) Tried to remove the comma using substitue but as my app supports multiple locale, people in some locale uses comma as decimal seperator hence can't remove comma.

Thanks in advance.

Hemanth
Hi All,

with below code I have completed the challenge thanks!!...When I tried to add this componet to Application and tried to check the UI part..I got below error, Can some one please let me know what the mistake is???

Something has gone wrong. [NoErrorObjectAvailable] Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 991118890-131685 (-1741317831) . Please try again.

APP:

<aura:application >
    <c:campingListItem />
</aura:application>


COMPONENT:

<aura:component >

    <aura:attribute name="item" type="Camping_Item__c" required="true"/>
    <ui:outputText value="{!v.item}"/>
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    <ui:outputCurrency value="{!v.item.Price__c}"/>
    <ui:outputNumber value="{!v.item.Quantity__c}"/>
    
    <ui:button label="packed!" press="{!c.packItem}" > 
    </ui:button>
</aura:component>


CONTROLLER:
({
    packItem: function(component, event, helper) {
        var a = component.get("v.item",true);
       
        a.Packed__c = true;
        component.set("v.item",a);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
    }
})


Thanks
Can someone help me with the test class for upload attachment and delete attachment, Bwlow is my vf page and controller:
 
VF Page:
<tr class="rowPt10">
                                            <td class="pb18 w20 textRight bold pr10 pl10" valign="top">
                                                <apex:outputText value="Attachments"/>
                                            </td>
                                            
                                            <td class="pb18 greyText">
                                                <apex:inputFile value="{!attachment.body}" fileName="{!attachment.name}" id="file"/>
                                                <apex:commandButton value="Upload" action="{!upload}" />
                                            </td>
                                            
                                        </tr>
          								<tr class="rowPt10">
                                            <td class="pb18 greyText">
                                            <apex:inputTextarea value="{!attachment.Description}"/>
                                            </td>
          										
          								</tr>
                                        <tr class="rowPt10">
                                            
                                            <td colspan="3" class = "leftPadding" >
                                                <apex:dataTable value="{!myList}" var="attachmentRow">
                                                    <apex:column >
                                                            <apex:commandLink action="{!DeleteAttach}" value="X"
                                                                styleClass="btnSave fs8 btnXpadding GreyText left mr10 rc2"
                                                                onclick="if(!confirm('Delete this attachment?')){event.preventDefault(); return false;};">
                                                                <apex:param name="deleteAttachmentId" value="{!attachmentRow.id}" assignTo="{!deleteAttachmentId}" />
                                                            </apex:commandLink>
                                                        </apex:column>
                                                    <apex:column >
                                                            <apex:outputLink value="{!URLFOR($Action.Attachment.Download,attachmentRow.Id)}" target="$_">
                                                                {!attachmentRow.Name}
                                                            </apex:outputLink>
                                                            &nbsp;&nbsp;
                                                            <apex:outputText value="[ By {!attachmentRow.CreatedBy.Name} on {!attachmentRow.CreatedDate}]"/>
                                                    </apex:column>
                                                </apex:dataTable>
                                            </td>
                                        </tr>
                                        
                                    </table>



Controller:


public class SF_AttachmentExecSummaryController {
    public string Pid{get;set;}
    public list<attachment> myList{get; set;}
    Public string deleteAttachmentId{get;set;}
    public SF_AttachmentExecSummaryController(){
        //Pid='a0o17000002AvZvAAK';
    	Pid =ApexPages.currentPage().getParameters().get('Pid');
        system.debug('id:::::'+Pid);
        loadAttachments();
    }
    
    public attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }

  public PageReference upload() {

    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = Pid; // the record the file is attached to
    attachment.IsPrivate = true;

    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
	loadAttachments();
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
    
    public void loadAttachments(){
        myList = new list<attachment>();//h
        myList = [SELECT CreatedDate,Name,CreatedBy.Name FROM Attachment where parentid =:Pid];//h
    }
    public void DeleteAttach() {
        if (deleteAttachmentId!=null){

             Attachment attachment = [SELECT Id, OwnerId, ParentId from attachment where Id = :deleteAttachmentId];
             //MnPriceApprovalAttachment__c mnPriceApprovalAttachment = [Select Id from MnPriceApprovalAttachment__c where Id=:attachment.ParentId];
             if(userinfo.getUserId()==attachment.OwnerId) {
                try{
                delete attachment ;
                }
                catch (DMLException e) {
                    System.debug('The following exception has occurred: ' + e.getMessage());
                }
            }

             loadAttachments();
        }
    } 
}

 
HI ,I am doing a trailhead on salesforce Lighting this is my code 

<aura:component >
    <aura:attribute name="item"  type="Camping_Item__c"  /> <!-- required="true" type="String"  -->
    <p> The Item is <ui:outputText value ="{!v.item}"></ui:outputText></p>
    <p>Name:
        <ui:outputText value="{!v.item.name}" /> 
    </p>

    <p>Quantity:
        <ui:outputNumber value="{!v.item.Quantity__c}" /> 
    </p>

    <p>Price:
        <ui:outputCurrency value="{!v.item.Price__c}" /> 
    </p>

    <p>Packed?:
        <ui:outputCheckbox value="{!v.item.Packed__c}" /> 
    </p>
    
    <p><ui:button label="Packed!" press="{!c.packItem}"></ui:button>
    </p>
</aura:component>



Now Its required of me to :
Add a button to the campingListItem component that when clicked, marks the item as packed.
1.Add a button labeled "Packed!" that calls the packItem controller function when clicked.
2.The controller action marks the item attribute as packed and disables the button.

I have done with the first point
I'm struggling with the second point.

the controller code looks something like this (which currently isnt working)

({
    packItem : function(component, event, helper) {
        var btn= event.getSource();
        var BtnMessage =btn.get("v.label");  
        component.set("v.item","Packed");          
        btn.disabled=false;
    }
})



each time I have failing the trailhead because of this error message
Challenge Not yet complete... here's what's wrong: 
The campingListItem JavaScript controller isn't setting the 'Packed' value correctly.