• piyush_soni
  • ALL STAR
  • 8301 Points
  • Member since 2016
  • Salesforce Developer
  • ACS


  • Chatter
    Feed
  • 265
    Best Answers
  • 14
    Likes Received
  • 16
    Likes Given
  • 2
    Questions
  • 1106
    Replies
trigger CreateRenewal on Opportunity (before update) {

  Map<Id, Opportunity> renewals = new Map<Id, Opportunity>();

  for (Opportunity opp : Trigger.new) {
 
    if (opp.CloseDate <= opp.CloseDate - 30) {
       Opportunity renewal = new Opportunity();
       renewal.AccountId   = 'opp.AccountId';
       renewal.Name        = opp.Name + 'Renewal';
       renewal.CloseDate   = opp.CloseDate + 365;
       renewal.StageName   = 'Open';
       renewal.RecordType  = 'Renewal';
       renewal.OwnerId     = opp.OwnerId;
       renewals.put(renewal.Id, renewal);
    }
  }

   insert renewals;
}

 
Hello, I am working on lightning component and stuck on scenario is there any way to switch one lightning component to another component when both are in different lightning pages.  
Please Help Me.
Thanks In Advance. :)
Hi, 

  I am using a below formula  Here Resller Discount = 25% and Margin = 7%
Disti discount% =  Margin% * (1-Reseller dicount%) + Reseller discount%
 If I use above formula in excel it is giving Disti Discount= 30.35%

 I am using the same formula in salesforce Apex but Disti Discount  is returning as 25% it self Please suggest me what might be the mistake in this math opeation I am doing
public PageReference addDistiDisc() {
        Decimal Margin = 7/100;
        Decimal Ddisc;
        Decimal Rdisc;
       for(QuoteLineWrapper qw : lines) {
         Rdisc = Decimal.Valueof(qw.qline.Reseller_Discount__c)/100;
         Ddisc = Margin  * (1 - Rdisc  ) + Rdisc ;
         qw.qline.Disti_Discount__c =  String.Valueof( (Ddisc) * 100);
         updateTotal(qw);
         qw.isChanged = true; 
        } 
      return null;
    }

Thanks
Sudhir
 
Hello, I thought I followed all the steps but I am getting and error. The field 'Contact__c' either does not exists on the Offer__c object or it is not lookup relationship. Here is a screenshot of the Fields & Relationships on the Offer Object. Please let me know what I am missing. Thanks! User-added image
Hi,

It was really simple to open URL in new window with passing parameters and some Validations using salesforce classic Onclick Java. for example:
if({!ISBLANK( Account.CSOne_Case_Number__c )})
{
window.open('https://.na29.visual.force.com/apex/Relationship360?rId={!Account.Gainsight_Relationship_ID__c}');
}

Now we are moving to Salesforce Lightning and As Onclick Javascript is not supported. can someone please let me know how can I achieve this in Lightning.

Thanks in advance.

Saurabh Sisodia
Hi,
I am new to salesforce, Please help me how to execute this batch class.
Thanks in Advance.


global class AccountBatch implements Database.batchable<sobject>
{
  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)
     {
     list<account> acc= new list<account>();
      for(account a:acc)
      {
        a.name= 'Mr' +a.name;
        acc.add(a);
        }
        
      update acc;
    }
    global void finish(database.batchablecontext bc)
    {
    }
    }
 
Hey dear Trailfriends,

I am pretty new to this, but I can't really seem to find this question yet, so I hope someone's able to help me out. I am currently training for Admin and there is this unit about Importing Data. Trailhead gave me this CSV-file which I am trying to upload, but in the screen about Field Mapping it keeps getting errors. One to be exact:

You need to map the required field Contact: Loan Amount.

So I am wondering: what can I do to get rid of this error? It is not really in the assignment, so I am wondering what I am doing wrong. There is no Loan Amount in the csv-file... Help!

Thanks :)
Apex Code =  ublic with sharing class Saveaccountdetail {
Public Account Account {get;set;}
Public Account Accts {get;set;}
Public Saveaccountdetail (){
Id id= ApexPages.currentPage().getParameters().get('id');
Accts = (id == null)? new Account() : [SELECT Name, Phone, Industry FROM Account WHERE Id = :id];
}
Public PageReference Save()
{try  
{
insert (Accts);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference redirectSuccess = new ApexPages.StandardController(Account).view();
return (redirectSuccess);
}
}

Visual Force Page 
<apex:page controller="Saveaccountdetail" tabStyle="Account" > <apex:form > <apex:pageBlock title="New Account"> <apex:pageBlockSection > <apex:inputField value="{!Account.name}" /> <apex:inputField value="{!Account.Industry}" /> <apex:inputField value="{!Account.Phone}" /> </apex:pageBlockSection> <apex:commandButton value="Save" action="{!Save}"/> </apex:pageBlock> </apex:form> </apex:page>
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
Hi Everyone, 

i have a faitly straight forward Visualforce page that takes the mobile number. I wanted to validate with Javascrip on the client side like below. 
 
<script>
         function jsCheckPhone()  
        {  
          var mobile = document.getElementById('pageId:formId:mobileId').value;  
          var normal = /^\d{10}$/;  
          if((mobile.value.match(normal))  
                {  
                document.getElementById('mobileMessageId').style.color = 'green';
                document.getElementById('mobileMessageId').innerHTML = 'Looks Good!';  
                }  
              else  
                {  
                document.getElementById('mobileMessageId').style.color = 'red';
                document.getElementById('mobileMessageId').innerHTML = '10 Digits Required';  
                }  
        }  
        </script>

And then later in the form I am calling it like this: 
 
<div role="listitem" class="freebirdFormviewerViewItemsItemItem">
                            <div class="freebirdFormviewerViewItemsItemItemTitle">Mobile <span style="color: #db4437;">*</span></div>
                        </div>
                        <div class="freebirdFormviewerViewItemsTextItemWrapper">
                            <apex:inputField onkeyup="jsCheckPhone();return false;" id="mobileId" value="{!contact.MobilePhone}" required="true" html-placeholder="Your answer" styleClass="freebirdText"/>
                        <span id="mobileMessageId"></span>
                        </div>

It does however never display anything next to the field. Could someone let me know what I am missing / If there would be a better way to have a phone number validated in Visualforce? 

Thanks. 
 
I have added notes and attachments to one of my Account, If I run the below query I am getting notes but not attachements
SELECT Id,name,(SELECT Id, Name FROM Attachments),(SELECT Id, Title FROM Notes) FROM Account
If I run seperate query on attachments, then also I am not getting any attachmants, the result is 0.
SELECT Id, Name FROM Attachment
Does anyone know why the count is getting zero? even though I have attachments in my org.
How do you set a dynamic aura attribute default value like current userinfo instead of hardcoding. See below.

The harcoding accountid works, not dynamic contactid/not supported.
 
<aura:attribute name="lookupcase" type="Case" default="{
		'sobjectType': 'Case',
        'ContactId': '{!v.userInfo.ContactId}',                                                
        'AccountId': '0012D000002oAkt'  
                                                         
	}"/>

 
I'm having difficulty using force:recordData to load some data for a record in a Lightning component.
 
<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="fieldsToQuery" type="Object"/>
    <aura:attribute name="recordError" type="String"/>
    <force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      layoutType="FULL"
                      targetRecord="{!v.record}"
                      targetError="{!v.recordError}"
                      targetFields="{!v.fieldsToQuery}"
                      />
    {!v.fieldsToQuery.Name}
    <br/>
    {!v.fieldsToQuery.MailingAddress}<br />
    {!v.fieldsToQuery.MailingCity}, {!v.fieldsToQuery.MailingState} {!v.fieldsToQuery.MailingPostalCode}<br />
    {!v.fieldsToQuery.MailingCountry}
</aura>

In the above, the data does not render on the page; if I try to specifically set the fields in force:recordData, it doesn't help either. Is there something I'm missing on this?
I'am unable to connect my dev org to trailhead. I got this below error

You are attempting to log into Trailhead to complete challenges with an org that isn't supported.
Please make sure that your Org is
A Developer Edition Org (it cannot be a Production or Sandbox Org) and
The Developer Edition Org does not have a namespace assigned to it.

My dev edition has a namespace assigned but i'm noble to connect it to my trailhead challenges, but i'm able to log on into the workbench using the same username.
Just trying to display the current user info on a lightning page
I'm an experienced Apex/Visualforce developer, and working on my first Lightning Component.

I get the impression that after I save/compile a modified Lightning bundle file (component or javascript), there is a delay before it becomes available in my sandbox instance. My Lightning component is invoked as a quick action on a custom object. If I hit save (in developer console or in my IDE, which is The Welkin Suite), and then refresh the lightning detail page and click the quick action button, it sure looks like the *old version of my code runs. If I refresh the detail page again, I sometimes get a "Sorry to Interrupt" popup. And then if I refresh again, I get the new code invoked.

Is there a delay between saving Lightning component code and the code actually being available in the sandbox instance?
Hello! 
Please help me with my VF page.
i need to update <p> from the CTPHARMA__Activity__c.SF1_Status__c (text formula) until y < 6 && z && u != "Win32" returns true
 
<apex:page standardController="CTPHARMA__Activity__c" id="page" docType="html-5.0">
<style>
.good{
text-align:center;
background-color: MediumSeaGreen;
font-weight: bold;
color: white;
}
.bad{
text-align:center;
background-color: Tomato;
font-weight: bold;
color: white;
}

.ugly{
text-align:center;
background-color: LightGray;
}


</style>
  
    <apex:form styleClass="{!if(CTPHARMA__Activity__c.SF1_Status__c == 'Подтвержден территориально','good',if(CTPHARMA__Activity__c.SF1_Status__c == 'Не подтвержден территориально','bad','ugly'))} ">

<p id="text"></p>

    </apex:form>
    
    
    <script>
    myFunction();
    function myFunction(){
    var x = {!CTPHARMA__Activity__c.SF1_Status__c};
    var y = {!CTPHARMA__Activity__c.SF1_Attempts__c};
    var z = {!CTPHARMA__Activity__c.SF1_Request_geo__c};
    var u = window.navigator.platform;
    
    do{
    
    document.getElementById("text").innerHTML = x;
     } 
     while (y < 6 && z && u != "Win32")
     }
     
    </script>
 
</apex:page>

 
I am working for a client request to develop a Opportunity Summary Page(Visualforce page), for which I need to show below recordds for the number of opportunities:

Opportunity NameAccount NameProducts NameAmountQuantitySubTotalNumber of ProductsTotal Payable AmountStageApproval History
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis
Hi
Can I resize lightning:inputRichText like a textarea's resize option?
User-added image

 
trigger CreateRenewal on Opportunity (before update) {

  Map<Id, Opportunity> renewals = new Map<Id, Opportunity>();

  for (Opportunity opp : Trigger.new) {
 
    if (opp.CloseDate <= opp.CloseDate - 30) {
       Opportunity renewal = new Opportunity();
       renewal.AccountId   = 'opp.AccountId';
       renewal.Name        = opp.Name + 'Renewal';
       renewal.CloseDate   = opp.CloseDate + 365;
       renewal.StageName   = 'Open';
       renewal.RecordType  = 'Renewal';
       renewal.OwnerId     = opp.OwnerId;
       renewals.put(renewal.Id, renewal);
    }
  }

   insert renewals;
}

 
Hello, I am working on lightning component and stuck on scenario is there any way to switch one lightning component to another component when both are in different lightning pages.  
Please Help Me.
Thanks In Advance. :)
I was wondering if anybody knew of a way to edit or add actions to a Kaban tile. Something along the lines of a send email action or a change record type action below the 'Change Owner' button in the picture below. Thank you in advance.
Actions that I would like to add to.
String sv1;
String sv2;
String sv3;
String sv4;
for(Opportunity o:[Select CampaignId,Site_Visit_1__c,Site_Visit_2__c,Site_Visit_3__c,Site_Visit_4__c From Opportunity Where CampaignId=:keysForOpp])
 {
     sv1=o.Site_Visit_1__c;
     sv2=o.Site_Visit_2__c;
     sv3=o.Site_Visit_3__c;
     sv4=o.Site_Visit_4__c;

}
If the custom fields are not filled in the records and I try to access them then I am encountering null pointer exception. Is there a way to validate the fields before accessing them? I tried placing those fields inside try-catch block but it  gets clumpsy since I need to write try-catch for every individual field. Is there an alternate way?
 
I know you can go to the Critical Updates screen in Setup to see the list of available updates, but what I'd like to know is if there is any way you can check if a critical update has been enabled via apex code?

Thanks
Tony
 
Hmm, here I am again, different question this time. 
When I try to make a page/event layout, I have to press the button below Salesforce Mobile and Lightning Experience Actions to be able to change it.
When I do it, it seems open, but there are a lot of fields I can't seem to put under Salesforce Mobile and Lightning Experience Actions... And I need to do it when following a Trailhead regarding Page Layouts.

Hope you can help!
select id,ValidationName,Active from Validationrule

I am not able to execute this query ..

I am getting "Invalid type: ValidationRule"
I am able to execute this query in query editor with tooling api enabled.
 

There is a option to link contacts to social profiles.http://salesforce.vidyard.com/watch/FZfHdKa6TuGog-JHzOlLDg . Where is social profile information stored and how do I retreive it in my application. 

In other words, I want to retreive the social profile details of my already created contact. 

Hello!

I'm relatively new to Salesforce and I'm facing some difficulties to show the Visualforce Spinner during CSV Export.
Currently on my Visualforce I have the following code:
<apex:commandButton disabled="{! lPermissaoExportar }" status="pageStatus" action="{! botaoExportar }" value="Exportar" reRender="mensagem, pageStatus"/>

<apex:actionStatus id="pageStatus">
        <apex:facet name="start">
            <apex:outputPanel >
                <img src="/img/loading32.gif" width="25" height="25" />
                <apex:outputLabel value="Carregando..."/>
            </apex:outputPanel>
        </apex:facet>
  </apex:actionStatus>
And on my controller:
if (this.lInicio == null || this.lFim == null || this.lInicio > this.lFim)
{
	Mensagem_erro__c mensagem = Mensagem_erro__c.getInstance();
	String cMensagem = (mensagem.VF_importar_erro_data__c != null) ? mensagem.VF_importar_erro_data__c : 'Data não preenchida ou Data de inicio maior que a data fim!';
	setMensagem(cMensagem);
	return null;
}

PageReference pg = new PageReference('/apex//RelatorioCaseCSV');
pg.getParameters().put('Inicio', EncodingUtil.urlEncode( String.valueOf(this.lInicio), 'UTF-8'));
pg.getParameters().put('Fim', EncodingUtil.urlEncode( String.valueOf(this.lFim), 'UTF-8'));
pg.getParameters().put('Status', EncodingUtil.urlEncode( this.lFltStatusCaso , 'UTF-8'));
pg.getParameters().put('Tipo', EncodingUtil.urlEncode( this.lFltTipoCaso , 'UTF-8'));
return pg;

If the first verification fails I return null, if it's fine I generate the instance of my CSV Export page and returns it.

The main problem here is that whenever I return null, the spinner works fine stopping after the processing has ended.
But when I return the PageReference, even it just making an download of the csv file, it never stops and keeps spinning forever.
Can anyone help me to solve this issue?
To end with this development I must show to the user that "something is happening", while the download doesn't begin.

Thank you!
 
Hi all,
I want to update CustomAmmount(Custom field) on parent(Opportunity) when child(OpportunityLineItem) updated
but its not working in after delete event
Trigger:
trigger UpdateCustomAmmount on OpportunityLineItem (after insert, after update, after Undelete,after delete) {
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUnDelete))
    {
    UpdateCustomAmmount_Handler.updateAmmount(Trigger.new);
    }
    
   /if(Trigger.isAfter ||Trigger.isDelete)
    {
      UpdateCustomAmmount_Handler.updateAmmount(Trigger.old);  
    }
}

Contoller:
public class UpdateCustomAmmount_Handler {
    public static void updateAmmount(List<OpportunityLineItem> olt)
    {
       
        List<Id> listIds = new List<Id>();
        system.debug('list of opp ids---'+listIds);
        
        for (OpportunityLineItem childItem : olt) {
            listIds.add(childItem.OpportunityId);
        }
        
          list<Opportunity> parentOpp = new List<Opportunity>([SELECT id, Custom_Ammount__c, Name,(SELECT ID, TotalPrice FROM OpportunityLineItems) FROM Opportunity WHERE ID IN :listIds]);
          system.debug('list of opp with child---'+parentOpp); 
          
        for(Opportunity opp:parentOpp)
               {
                   opp.Custom_Ammount__c = 0;
            for(OpportunityLineItem item:opp.OpportunityLineItems)
            {
               
                opp.Custom_Ammount__c += item.TotalPrice; 
               }
            }
        If(parentOpp.size()>0){
            update parentOpp;  
        }    
    }
}
 
Hi all,

Another question from me: I am still working on the admin module within Trailheads and I cant finish it, because in the Create object specific quick actions-part I can't seem to find Properties under Tabs. I did create Property/Properties as an object, but then I have to do this:

Enter Tab in the Quick Find box, then select Tabs.
In the Custom Object Tabs list, click New.
In the Object dropdown list, select Property.

And in that object dropdown list, there is no Property. Can someone tell me what to do here, please? Thanks! :)
Hi, 

  I am using a below formula  Here Resller Discount = 25% and Margin = 7%
Disti discount% =  Margin% * (1-Reseller dicount%) + Reseller discount%
 If I use above formula in excel it is giving Disti Discount= 30.35%

 I am using the same formula in salesforce Apex but Disti Discount  is returning as 25% it self Please suggest me what might be the mistake in this math opeation I am doing
public PageReference addDistiDisc() {
        Decimal Margin = 7/100;
        Decimal Ddisc;
        Decimal Rdisc;
       for(QuoteLineWrapper qw : lines) {
         Rdisc = Decimal.Valueof(qw.qline.Reseller_Discount__c)/100;
         Ddisc = Margin  * (1 - Rdisc  ) + Rdisc ;
         qw.qline.Disti_Discount__c =  String.Valueof( (Ddisc) * 100);
         updateTotal(qw);
         qw.isChanged = true; 
        } 
      return null;
    }

Thanks
Sudhir
 
Hi,

I try to make a quik action and a lightning component to create a quote :

Component.CMP
<aura:component controller="QuickQuoteController" 
                implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">

    <aura:attribute name="opportunity" type="Opportunity" />
    <aura:attribute name="newQuote" type="Quote"
        default="{ 'sobjectType': 'Quote' }" />
    
    <!-- default to empty record -->
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <!-- Display a header with details about the opportunity -->
    <div class="slds-page-header" role="banner">
        <p class="slds-text-heading_label">{!v.opportunity.Name}</p>
        <h1 class="slds-page-header__title slds-m-right_small
            slds-truncate slds-align-left">Créer un nouveau devis</h1>
    </div>

    <!-- Display the new quote form -->
     <lightning:input aura:id="quoteField" name="name" label="Name"
                      value="{!v.newQuote.Name}" required="true"/>

    <lightning:input aura:id="quoteField" type="date" name="date" label="Date"
                     value="{!v.newQuote.Date}" required="true"/>
    
    <lightning:button label="Cancel" onclick="{!c.handleCancel}" class="slds-m-top_medium" />
    <lightning:button label="Save Quote" onclick="{!c.handleSaveQuote}"
               variant="brand" class="slds-m-top_medium"/>
    
</aura:component>

Controller.JS
({
    doInit : function(component, event, helper) {

        // Prepare the action to load opportunity record
        var action = component.get("c.getOpportunity");
        action.setParams({"opportunityId": component.get("v.recordId")});

        // Configure response handler
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS") {
                component.set("v.opportunity", response.getReturnValue());
            } else {
                console.log('Problem getting opportunity, response state: ' + state);
            }
        });
        $A.enqueueAction(action);
    },

    handleSaveQuote: function(component, event, helper) {
        if(helper.validateQuoteForm(component)) {
            
            // Prepare the action to create the new quote
            var saveQuoteAction = component.get("c.saveQuoteWithOpportunity");
            saveQuoteAction.setParams({
                "quote": component.get("v.newQuote"),
                "opportunityId": component.get("v.recordId")
            });

            // Configure the response handler for the action
            saveQuoteAction.setCallback(this, function(response) {
                var state = response.getState();
                if(state === "SUCCESS") {

                    // Prepare a toast UI message
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "title": "Quote Saved",
                        "message": "The new quote was created."
                    });

                    // Update the UI: close panel, show toast, refresh quote page
                    $A.get("e.force:closeQuickAction").fire();
                    resultsToast.fire();
                    $A.get("e.force:refreshView").fire();
                }
                else if (state === "ERROR") {
                    console.log('Problem saving quote, response state: ' + state);
                }
                else {
                    console.log('Unknown problem, response state: ' + state);
                }
            });

            // Send the request to create the new quote
            $A.enqueueAction(saveQuoteAction);
        }
        
    },

	handleCancel: function(component, event, helper) {
	    $A.get("e.force:closeQuickAction").fire();
    }

})

Helper.JS
({
    validateQuoteForm: function(component) {
        var validQuote = true;

        
        // Show error messages if required fields are blank
        var allValid = component.find('quoteField').reduce(function (validFields, inputCmp) {
            inputCmp.showHelpMessageIfInvalid();
            return validFields && inputCmp.get('v.validity').valid;
        }, true);

        if (allValid) {
        // Verify we have an opportunity to attach it to
        var opportunity = component.get("v.opportunity");
        if($A.util.isEmpty(opportunity)) {
            validOpportunity = false;
            console.log("Quick action context doesn't have a valid opportunity.");
        }

        return(validOpportunity);
	}
    }
})

Controller.APXC
public with sharing class QuickQuoteController {

    @AuraEnabled
    public static Opportunity getOpportunity(Id opportunityId) {
        // Perform isAccessible() checks here
        return [SELECT Name FROM Opportunity WHERE Id = :opportunityId];
    }
    
    @AuraEnabled
    public static Quote saveQuoteWithOpportunity(Quote quote, Id opportunityId) {
        // Perform isAccessible() and isUpdateable() checks here
        quote.OpportunityId = opportunityId;
        upsert quote;
        return quote;
    }

}
I have an issue and I can't find where it comes :
 
Uncaught Action failed: c:quickQuote$controller$handleSaveQuote [validOpportunity is not defined]

markup://c:quickQuote

Object.validateQuoteForm()@https://org--dev.lightning.force.com/one/components/c/quickQuote.js:89:9
handleSaveQuote()@https://org--dev.lightning.force.com/one/components/c/quickQuote.js:27:19
handleClick()@https://org--dev.lightning.force.com/components/lightning/button.js:1:470

Any idea ?
 
Hi 

I have scnerio where I need to capture IP address of current User in Lightning Community, is any way standard way  where I can capture IP address inside Lightning Components.
I have seen third party tools like - https://www.ipify.org/ to get Ip address 
Any recommendations are appreciated 

Thanks 
Hi all,

Im currently facing an issue with the "e.force:createRecord" when trying to pre populate some fields from an object to another one. Im using the "defaultFieldValues" and almost every field is populated correctly (Lookup, text,etc) except Currency and Master-Detail.

For your understanding of the issue, when i query the data and show it on the console its shows completly fine ("234" currency field), but at the moment to pre populate it just dont, it keeps the field blank. Also ive tried to: ParseInt, Integer the value, and nothing.
Also, the fuctionallity on Classic mode it working fine, so its not a permision issue (Profile, FLS,etc).

Do you know why is this happenening? Happens to 2 different currency field and also to the master-detail (havent reasearch or even tried anything on this but if you can help also i will appreciate it).

Thanks!!
Hi All,

Getting the below error when i click on quick action containing a lightning component. 
Action failed: forceChatter:lightningComponent$controller$doInit (undefined is not an object (evaluating 'fn-apply')]

quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent

Let me know what the issue could be.
<aura:component controller="SOWManager_CTL" implements="flexipage:availableForAllPageTypes">

      <aura:attribute name="theaters" type="String[]"/>
      <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
      <form>      
           <div class="header">
               <div style="margin-left:15%;float: left; margin-top:0.5%;" >
                 SOW ID : <ui:outputText aura:id="sowID"  value="{!v.Name}" />
             </div>
             <div style="margin-left:50%;float: left;margin-top:0.5%;">
                 SOW Status : <ui:outputText aura:id="sowStatus"   value="{!v.SOW_Status__c}" />
             </div>
         </div>     
        <lightning:tabset >
        <lightning:tab label="General Info">
             <fieldset class="slds-form--compound" style="margin-left:15%;margin-right:15%">
               <div class="slds-form-element__group">
                <div class="slds-form-element__row">
                  <div class="slds-form-element slds-size--1-of-2">
                      <lightning:select  name="theaterGeo"  label="Theater/Geography" required="true">
                          <option value="" text="Select Theater/Org"></option>
                          <aura:iteration items="{!v.theaters}" var="theater">
                            <option value="{!theater}" text="{!theater}"></option>
                        </aura:iteration>
                    </lightning:select>
                  </div>
                  <div class="slds-form-element slds-size--1-of-2">
    
                   </div>
                </div>
              </div>
            </fieldset>
        </lightning:tab>
 
    </lightning:tabset>

        
       
    </form>
</aura:component>
HI,
I am working on lightning component where I need progress indicator. I am using slds progress indicator but it is not showing css same as shown in the slds guide.
I have used the same code mentioned in the guide.https://www.lightningdesignsystem.com/components/progress-indicator/#flavor-base-default
But still it is not showing connecting line of two button. please find screenshot of issue.User-added image
According to guide image bar should look likeUser-added image

Please help me on the same

Thanks
Shikha
One approach we have tried is having a Lightning Component with a button and adding the component to the specific record page, however this approach makes the UI inconsistent.
Is there a way for one component to reference the functions in another without embedding?

If I have to embed the component, how do I reference there parent function from a  child component and vice versa?
Hi folks, 

I try to complete the "Build a Battle Station App" -> Modify the User Experience. Trail to complete. I checked everything and did it 3 times but every time I get the error:

Challenge Not yet complete... here's what's wrong: 
The 'Resources' related list was not found on the Page Layout 
Note: you may run into errors if you've skipped previous steps.

The Resources Column is in the Page Layout and I add the needed objects. 

Anybody an Idea?
Hi All,
Is there a way to bookmark a question from this forum?
Suppose a come across a question and I want to bookmark that question for future refrence. Can I do that?
Currently I am commenting on the already answered questions as a way to bookmark it.

Thanks,
Sathwick
Hi,
I was going through practice session about constructors but my program keeps on failing

I used the code:
public class TestObject2{
    private static final Integer DEFAULT_SIZE = 10;

    Integer size;

   //Constructor with no arguments
   public TestObject2() {
       this(DEFAULT_SIZE); // Using this(...) calls the one argument constructor    
   }

   // Constructor with one argument 
   public TestObject2(Integer ObjectSize) {
     size = ObjectSize;  
   }
}


and At Execute Anonymous Window Giving:

TestObject2 myObject1 = new TestObject2(42);
TestObject2 myObject2 = new TestObject2();

I am getting an error:

Line: 1, Column: 25
Constructor not defined: [TestObject2].<Constructor>(Integer)

What is wrong here?
trigger AddRelatedRecord on Account (after insert, after update) 
{
  list<opportunity> opplst = new list<opportunity>();
    Map<ID,Account> acctsWithOpps = new Map<ID,Account>([select id,(select id from opportunities) from Account where id IN: Trigger.New]);
    
    for(Account a: Trigger.New)
    {
        if(acctsWithOpps.get(a.Id).Opportunities.Size()==0)
        {
            opplst.add(new opportunity(Name=a.Name + 'opportunity',StageName='Prospecting',CloseDate=System.today().addMonths(1),AccountId=a.Id));
        }
    }
    if(opplst.size()>0)
    {
        insert opplst;
    }
}


User-added image
Hi Folks,

This is more of an FYI post and for those of you who have not noticed it yet. The developer console comments in component markups interers with the SLDS classes with "--" in the class name.

Temporary solution - Change/remove all the "--"'s from the class name in the markup for the code you are trying to comment.

Example:
The below code cannot be commented with <!-- code -->
<div class="slds-spinner--inverse slds-spinner slds-spinner--large" aria-hidden="false" role="alert">
You will need to remove the "--" from the class name inorder for the comment to work in dev console.
<!-- changed "--inverse" to "-inverse" and "--large" to "-large"
  <div class="slds-spinner-inverse slds-spinner slds-spinner-large" aria-hidden="false" role="alert">
-->
Cheers!
  • August 31, 2016
  • Like
  • 1
hii friends please suggest me  test class for this  below. i have also written one test class but showing error
Trigger RevenueWithoutST on Revenue__c (before insert,Before Update) {

    List<SCSCHAMPS__Appointment__c> appList;
    List<Revenue__c> revlist = new List<Revenue__c>();
    string eCode;
    date salaryDate;
    string category;
    string type;
    Integer month;
    Integer year;
    
    for(Revenue__c rev:Trigger.new)
    {
        eCode=rev.ECode__c;
        salaryDate=rev.Salary_Processed_Month__c;
        month=rev.Salary_Processed_Month__c.month();
        year=rev.Salary_Processed_Month__c.year();
        category=rev.InvoiceCategory__c;
        type=rev.Invoice_Type__c;      
        if(eCode!=null)
        {
           appList =[select AvvasECode__c,Name_of_the_Candidate__c,Client_Name__c,Date_of_Onboarding__c,Last_Working_Date__c,Location__c from SCSCHAMPS__Appointment__c where AvvasECode__c=: ecode] ;
            
            for(SCSCHAMPS__Appointment__c app : appList)
            {
               rev.Talent_Name__c= app.Name_of_the_Candidate__c;
               rev.Client_Name__c=app.Client_Name__c;
               rev.DOJ__c=app.Date_of_Onboarding__c;
               rev.Last_Working_Date__c=app.Last_Working_Date__c;
               rev.Location__c=app.Location__c;
            }
        }

        if((eCode!=null) && (category=='individual') &&(salaryDate!=NULL) )
        {
            List<Invoice__c> InvList;                                                                              
            InvList=[select id,Name,Emp_Code__c,Invoice_Category__c,Sub_Total__c,Invoice_Date__c from Invoice__c where Emp_Code__c=: ecode
                    AND CALENDAR_MONTH(Invoice_Date__c)=:month AND CALENDAR_YEAR(Invoice_Date__c)=:year ];
              System.debug('+++invoice'+InvList);
              
              
                FOR(Invoice__c inc : InvList)
                {
                  
                  rev.Revenue_Without_ST__c=inc.Sub_Total__c;
                }

        }

        else if(eCode!=null && category=='consolidated')
        {

            List<Invoice_Line_Item__c> ILineList;
         // Invoice_Line_Item__c iline=new Invoice_Line_Item__c();
            ILineList=[select id,Name,Employee_Code__c,Total__c,Invoice_Date__c from Invoice_Line_Item__c where Employee_Code__c=:ecode
                        AND CALENDAR_MONTH(Invoice_Date__c)=:month AND CALENDAR_YEAR(Invoice_Date__c)=:year ];
            for(Invoice_Line_Item__c IL : ILineList)
            {
              rev.Revenue_Without_ST__c=IL.Total__c;
            }
        }
           
    }
 
    }
Here is my  test class but showing error and not executing properly
@isTest
public class testRevenue {
        static testMethod void testMethod1()  {
 InvoiceCategory__c InvC = newInvoiceCategory__c(name = 'Test1');    
                  insert InvC;                      
Invoice_Type__c InvT = new Invoice_Type__c(name = 'Test2');                   
  insert  InvT;
Salary_Type__c SalT = new ISalary_Type__c(name = 'Test2');                   
  insert  SalT
       
            Test.StartTest();               
                Revenue__c rev= new Revenue__c();
                rev.ECode__c='Test0';
                InvoiceCategory__c invC = new InvoiceCategory__c
                List<SelectOption> listInvCt = rev.InvoiceCategory__c();
                List<SelectOption> listInvTy = rev.Invoice_Type__c();
                List<SelectOption> listSalTy = rev.Salary_Type__c();
                rev.SelInvoiceCategory__c ='Test1';
                rev.SelInvoice_Type__c ='Test2';
                rev.SelSalary_Type__c ='Test3';
                rev.Salary_Processed_Month__c=system.today();
Test.StopTest();
        }
    }

Here is my  test class but showing error and not executing properly
@isTest
public class testRevenue {
        static testMethod void testMethod1()  {
 InvoiceCategory__c InvC = newInvoiceCategory__c(name = 'Test1');    
                  insert InvC;                      
Invoice_Type__c InvT = new Invoice_Type__c(name = 'Test2');                   
  insert  InvT;
Salary_Type__c SalT = new ISalary_Type__c(name = 'Test2');                   
  insert  SalT
       
            Test.StartTest();               
                Revenue__c rev= new Revenue__c();
                rev.ECode__c='Test0';
                InvoiceCategory__c invC = new InvoiceCategory__c
                List<SelectOption> listInvCt = rev.InvoiceCategory__c();
                List<SelectOption> listInvTy = rev.Invoice_Type__c();
                List<SelectOption> listSalTy = rev.Salary_Type__c();
                rev.SelInvoiceCategory__c ='Test1';
                rev.SelInvoice_Type__c ='Test2';
                rev.SelSalary_Type__c ='Test3';
                rev.Salary_Processed_Month__c=system.today();
Test.StopTest();
        }
    }
 
We have an active community with a visualforce page with the following code:

<apex:page >
<flow:interview name="New_User_Flow"/>
</apex:page>

When you navigate to this page within the community: https://XXX.force.com/New_User_Flow it shows error:

https://XXX.force.com is down for maintenance Sorry for the inconvenience. We'll be back shortly. Please email us if you need to get in touch.

This visualforce page has been added under "Public Access Settings" for the community profile (Community > Admin > Pages > Go to Force.com).

How can we make this page accessible? It should display a flow as per visualforce page.

Hi friends, do you know the code (Apex or Javacript) to open the Salesforce PDF Viewer but with a PDF i created manually? Not the templates you can create with salesforce.

 

cheers

  • October 18, 2012
  • Like
  • 2

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.