• Pabitra
  • NEWBIE
  • 100 Points
  • Member since 2019

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 17
    Replies
Hi all,

I am trying to write information from the opportunitylineitem to the opportunity. On the LineItem there is a field called Product which is a standard lookup field to the product object. I am trying to get that name to go from the LineItem to the Opportunity to a custom field called product. When I was trying to reference the Standard lookup product I kept getting an error message saying it wasn't a field so changed it to the description to see if i could get the description to go from the LineItem to the Opportunity. The trigger did save but it didn't work so I wanted to post my code here to see if anyone could help.

So my first question is how do I reference a standard lookup field in apex and the second is this the best way to get information from the LineItem to the opportunity?
 
trigger OpportunityProductTrigger on OpportunityLineItem (after update) {

List<Id> oppIds = new List<Id>();
String Item;

    if(trigger.isAfter) {
        for (OpportunityLineItem oli: trigger.new){
            oppIds.add(oli.opportunityID);
        }
        List<OpportunityLineItem> allOLI = [SELECT id, ProductCode FROM OpportunityLineItem WHERE OpportunityId in: oppids];
        List<Opportunity> oppsToUpdate = [SELECT id, Product__c FROM Opportunity WHERE id in: oppids];
        if(allOLI.size() > 0){
          for(OpportunityLineItem allOLI2: allOLI){
                    Item = allOLI2.ProductCode;
                }//END if(allOLI2.Number_of_Months__c > contractLengthMonths)
            } //END for(OpportunityLineItem allOLI2: allOLI)
            for(Opportunity oppUpdate: oppsToUpdate){
                oppUpdate.Product__c = Item;
            }// END for(Opportunity oppUpdate: oppsToUpdate)
 
        }

}

Thanks for your help,
Ed
Hello,
I am using a Web to Lead form for volunteer signup on the web site. I wanted to pass two hidden parameters to set values on the lead object, when the form is submitted.

These are the two lines of code I added to the form:
"
<input type=hidden name="leadsource" id="leadsource" value="Web Volunteer Form">
<input type="hidden" name="00N1U00000GRdQD" id="00N1U00000GRdQD" value="New Sign Up">
"
The custom field that comes with VS4 is set correctly (second line of code).
I can not get the first line of code to work. Standard Lead source field can not be set with this code.

Any help would be appreciated.

Here is the help page for the functionality for reference: https://help.salesforce.com/articleView?id=000327328&type=1&mode=1

And a final note; I tried using the field API name with capital letters in it. Same result.
Hi all,

We use workflows to send Invoice reminder in our org. We use the email alert option, and in the Recipients field I choose: Email Field: Contact Email and the email is sent to the contact on the opportunity, which works fine.

Now, I need to send this same kind of alert to the client directly instead of the opportunity contact. It would be the same email address for all the invoices, but this contact is not a org user, just a regular contact in our system. Is there a way to send them a notification?

Thanks
Hi,

I am creating an LWC, where I am trying to do in multiple dynamic row entering record details and doing Quick Save. In Quick save function in js file i am sending the list value to Apex class method and doing upsert there and returning inserted records list to js file again from that same method. So that I can show in the same page and do update to the same record. But I unable to return that list to js file from apex. So if I do some modification and quick save it is creating another record instad of update (as id not there ). Can anyone help me on this how can i achieve it?

Thanks in advance!!
When i am going to run a test class, i am facing the belo error.
FYI, the inserted account is integrated with xero.Kindly assist me.Thanks in advance.


System.NoDataFoundException: Data Not Available: The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our <A href="javascript:openPopupFocusEscapePounds('https://help.salesforce.com/apex/htdoor?body=%2Ftrain%2FonlineSupport.jsp&loc=support&language=en_US&release=224.14.4&instance=CS110', 'Help', 1024, 768, 'width=1024,height=768,resizable=yes,toolbar=yes,status=yes,scrollbars=yes,menubar=yes,directories=no,location=yes,dependant=no', false, false);" title="support (New Window)">support</a> page.
From one custom object I am retrieving one DateTime field and comparing with another dateTime field in apex. But what the Date Time field I am retrieving to apex from object, the different time showing. May be it's happening based on my user time zone.But I want this should come in apex same how it is in record.I'm not bothering about time format.But bothering about correct time value only.For matching the both time I don't want to add any hours by hard coded. Because the hard coded hours mayn't be perfect solution for all kindof time zone.Can anyone help me please?
I have a formula field of hyperlink type.I am using it in visualforce.But in vf page it is showing the url directly.So I used apex:outputText, so that it is showing the text with hyperlink.But I don't want the hyperlink also here.I want to show only text.So how can I do this?

Note:As of now I have tried with text-decoration-none and I don't want to create another field. Escape attribute not supported in apex:outputText.Kindly give any suggestion apart from this.
I have developed a vfpage which is rendering as PDF. but issue is it is not previewing in Salesforce mobile app rather it is redirecting to my mobile browser or asking Salesforce app? So how can I achieve it and can able to download in salesforce mobile app itself?Thanks in advance!
I want to achieve in lightnign experience(may be through lightning component or lightning flow or lightning web component ), place a button on record detail page.This button functionality almost same with standard clone button feature.But here we are cloning the record with certain fields.Edit window also came before save the record where we can able to change record values whereever we want(may be any look up field,picklist field or text field).Can any one guide please?Thanks in advance.
When i am going to run a test class, i am facing the belo error.
FYI, the inserted account is integrated with xero.Kindly assist me.Thanks in advance.


System.NoDataFoundException: Data Not Available: The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our <A href="javascript:openPopupFocusEscapePounds('https://help.salesforce.com/apex/htdoor?body=%2Ftrain%2FonlineSupport.jsp&loc=support&language=en_US&release=224.14.4&instance=CS110', 'Help', 1024, 768, 'width=1024,height=768,resizable=yes,toolbar=yes,status=yes,scrollbars=yes,menubar=yes,directories=no,location=yes,dependant=no', false, false);" title="support (New Window)">support</a> page.
Hi,

I am creating an LWC, where I am trying to do in multiple dynamic row entering record details and doing Quick Save. In Quick save function in js file i am sending the list value to Apex class method and doing upsert there and returning inserted records list to js file again from that same method. So that I can show in the same page and do update to the same record. But I unable to return that list to js file from apex. So if I do some modification and quick save it is creating another record instad of update (as id not there ). Can anyone help me on this how can i achieve it?

Thanks in advance!!
Hi all,

I am trying to write information from the opportunitylineitem to the opportunity. On the LineItem there is a field called Product which is a standard lookup field to the product object. I am trying to get that name to go from the LineItem to the Opportunity to a custom field called product. When I was trying to reference the Standard lookup product I kept getting an error message saying it wasn't a field so changed it to the description to see if i could get the description to go from the LineItem to the Opportunity. The trigger did save but it didn't work so I wanted to post my code here to see if anyone could help.

So my first question is how do I reference a standard lookup field in apex and the second is this the best way to get information from the LineItem to the opportunity?
 
trigger OpportunityProductTrigger on OpportunityLineItem (after update) {

List<Id> oppIds = new List<Id>();
String Item;

    if(trigger.isAfter) {
        for (OpportunityLineItem oli: trigger.new){
            oppIds.add(oli.opportunityID);
        }
        List<OpportunityLineItem> allOLI = [SELECT id, ProductCode FROM OpportunityLineItem WHERE OpportunityId in: oppids];
        List<Opportunity> oppsToUpdate = [SELECT id, Product__c FROM Opportunity WHERE id in: oppids];
        if(allOLI.size() > 0){
          for(OpportunityLineItem allOLI2: allOLI){
                    Item = allOLI2.ProductCode;
                }//END if(allOLI2.Number_of_Months__c > contractLengthMonths)
            } //END for(OpportunityLineItem allOLI2: allOLI)
            for(Opportunity oppUpdate: oppsToUpdate){
                oppUpdate.Product__c = Item;
            }// END for(Opportunity oppUpdate: oppsToUpdate)
 
        }

}

Thanks for your help,
Ed
Hi All

I have a problem at the moment where i am trying to access a variable in the controller which i am creating in APEX but i cannot pull it through. Any suggestions would be great!

APEX
@AuraEnabled
    public static Senior_Parking_Permit__c checkPermit(String permitNumber){
        system.debug('Hit the server');
        system.debug(permitNumber);
        
        User currUser = getCurrPortalUser();
        system.debug('currUser =  ' + currUser );
         
        if (currUser.ContactId == null ) return null;
        
        List<Senior_Parking_Permit__c> foundPermits = [SELECT Id, Name, Permit_Number__c, Claimed__c FROM Senior_Parking_Permit__c 
                                                               WHERE Permit_Number__c = :permitNumber
                                                               LIMIT 1];
        
        if(foundPermits.size() == 0) {
            system.debug('Could not find any matching Senior_Parking_Permit__c rec, do nothing ');
            
            return null;
        }
        else{
            Senior_Parking_Permit__c foundPermit = foundPermits[0];
            
            if(foundPermit.Claimed__c == true){
                
                Boolean Claimed = true;
            }
            else {
                Boolean Claimed = false;
            }
            
            system.debug('Found a Senior_Parking_Permit__c record - ' + foundPermit);
            system.debug('... and it hasnt been claimed yet, lets claim it. ');
            
            foundPermit.Claimed__c = true;
            system.debug('Before update foundPermit  - ' + foundPermit);
            
            update foundPermit;
            return foundPermit;
        }
    }

Controller
permitClaim : function(component, event, helper){
        var action = component.get("c.checkPermit");
        var permitNumber = component.get("v.simpleNewCase.Permit_Number__c");
        
        console.log("permitNumber",permitNumber);
        
        action.setParams({
            permitNumber : permitNumber
        });
        
        action.setCallback(this, function(a) {
            
            var state = a.getState();
            console.log("State",state);
            var permitData = a.getReturnValue(); 
            console.log("permitData",permitData);
            
            if(permitData === null){
                debugger;
                var permitNotFound = true;
                component.set("v.permitNotFound",true);
                console.log(permitNotFound);
            }
            
            if(a.getState() === 'SUCCESS'){
                
                if(permitData != null){
                    debugger;
                component.set("v.foundPermit",permitData.Permit_Number__c);
                component.set("v.permitClaimed",permitData.Claimed);
                    
                var permitFound = component.get("v.foundPermit");
                console.log("permitNumber",permitNumber);
                    
                var permitClaimed = component.get("v.permitClaimed");
                console.log("permitClaimed",permitClaimed);
                    
                var permitNotFound = false;
                component.set("v.permitNotFound",false);
                console.log(permitNotFound);
                    
                }
                
                if((permitFound == permitNumber) && (permitClaimed === false)){
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Found",
                        "type" :"Success",
                        "message": "Your existing parking permit has been found."
                    });
                    showToast.fire();
                } else if ((permitFound == permitNumber) && (permitClaimed === true)){
                    
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Already Claimed",
                        "type" :"error",
                        "message": "The parking permit number you have selected has already been claimed. If this has been claimed incorrectly, please contact Customer Services."
                    });
                    showToast.fire();
                } else if(permitNotFound === true){
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Not Found",
                        "type" :"error",
                        "message": "The parking permit number you have entered has not been recognised. Please try again."
                    });
                    showToast.fire();
                }
            }
            
        });
        $A.enqueueAction(action);
    }
I am trying to get the attribute 'Claimed' to appear with a simple true or false but cant get it to work. 

Thanks for your help!

Tom 
 
Hello there,

I am working on a visual force page that it is used as a Web to Lead form. I would like to add a new comment box. I added the code below but it somehow adds a predifine text when I try to submit the form. Also , I need a big comment box ( I need to add up to 500 characters) but the one that shows it is very small.

<div class="form-group">
                            <label for="description"> Tell us what interest you and how we can help *</label>
                           
                            <input type="text" id="description" ng-model="data.description" name="description" ng-required="true" class="form-control" ng-disabled="waiting" ng-pattern="textPattern2" maxlength="500"/>
                            <span ng-class="{active:form.description.$invalid&&(form.description.$touched || showErrors)}"
                                  class="ui-state-error message">Tell us what interest you and how we can help.</span>
                        </div>
Thank you in advance.
Amy
Hello,
I am using a Web to Lead form for volunteer signup on the web site. I wanted to pass two hidden parameters to set values on the lead object, when the form is submitted.

These are the two lines of code I added to the form:
"
<input type=hidden name="leadsource" id="leadsource" value="Web Volunteer Form">
<input type="hidden" name="00N1U00000GRdQD" id="00N1U00000GRdQD" value="New Sign Up">
"
The custom field that comes with VS4 is set correctly (second line of code).
I can not get the first line of code to work. Standard Lead source field can not be set with this code.

Any help would be appreciated.

Here is the help page for the functionality for reference: https://help.salesforce.com/articleView?id=000327328&type=1&mode=1

And a final note; I tried using the field API name with capital letters in it. Same result.
User-added image
Upload Files Button is showing Disable in Flow, I have given everything which is required, need help
Hi all,

We use workflows to send Invoice reminder in our org. We use the email alert option, and in the Recipients field I choose: Email Field: Contact Email and the email is sent to the contact on the opportunity, which works fine.

Now, I need to send this same kind of alert to the client directly instead of the opportunity contact. It would be the same email address for all the invoices, but this contact is not a org user, just a regular contact in our system. Is there a way to send them a notification?

Thanks
Hello,

I am trying to push an Apex Class which auto converts a lead into a contact.  When I try to deploy this in production I get the following error.  I am not too familiar with Apex Classes and not sure how to resolve this.

Your code coverage is 38%. You need at least 75% coverage to complete this deployment.
 
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Leadconvert.setConvertedStatus(Leads.MasterLabel);
            Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to   create an opportunity from Lead Conversion 
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}


Any help is much appreciated.

Thanks,

Aaron
 
I have developed a vfpage which is rendering as PDF. but issue is it is not previewing in Salesforce mobile app rather it is redirecting to my mobile browser or asking Salesforce app? So how can I achieve it and can able to download in salesforce mobile app itself?Thanks in advance!
I want to achieve in lightnign experience(may be through lightning component or lightning flow or lightning web component ), place a button on record detail page.This button functionality almost same with standard clone button feature.But here we are cloning the record with certain fields.Edit window also came before save the record where we can able to change record values whereever we want(may be any look up field,picklist field or text field).Can any one guide please?Thanks in advance.
Hi all,

Can anyone help me to know why we use visualforce pages instard of standard page. We can customiize the standard pages but why do we use visual force page in salesforce.

Thanks in advance,

regards,
naga