• Mark Moser 10
  • NEWBIE
  • 25 Points
  • Member since 2020

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
I am running into cpu limit with this am I am missing somthing? And also how can I adjust the code to avoid harcoding the ID like i did.
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted ) {
               Database.LeadConvert lc = new Database.LeadConvert();
            
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(TRUE); 
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
                String leadOwner = lead.OwnerId;
              if(leadOwner.startsWith('00G')){
               Lc.OwnerId = '00535000001ZOZN'; }
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}

 
i coded tested, then exposed in partner community and it does not work at all
I tried to use platform events; they work in my lwc that is unsed in salesforce.  i expose the same lwc to partner community and it does not work. same lwc; same code
Component:

 <aura:iteration items="{!v.fields}" var="f">
              <aura:if
                isTrue="{!((v.recordId==null&amp;&amp;f.fieldPath=='genesis__Business_Name__c'))}"
              >
                <aura:if
                  isTrue="{!and(not(v.newAccount), empty(v.tradeUpDetails))}"
                >
                  <lightning:inputField
                    fieldName="genesis__Account__c"
                    aura:id="inputFieldAccountName"
                    class="input-is-required"
                    onchange="{!c.lookupChange}"
                    value="{!v.accountId}"
                    autocomplete="nope"
                  />
                  <aura:set attribute="else">
                    <lightning:inputField
                      fieldName="genesis__Business_Name__c"
                      aura:id="inputFieldAccountId"
                      class="input-is-required"
                      autocomplete="nope2"
                    />
                  </aura:set>
                </aura:if>
              </aura:if>
              <aura:if

Helper:

 var inputAccountName = component.find("inputFieldAccountName");
 console.log(inputAccountName.get("v.value"));

gets exception on var input account name but just stops running at that point

 
I tried to use platform events; they work in my lwc that is unsed in salesforce.  i expose the same lwc to partner community and it does not work. same lwc; same code
Component:

 <aura:iteration items="{!v.fields}" var="f">
              <aura:if
                isTrue="{!((v.recordId==null&amp;&amp;f.fieldPath=='genesis__Business_Name__c'))}"
              >
                <aura:if
                  isTrue="{!and(not(v.newAccount), empty(v.tradeUpDetails))}"
                >
                  <lightning:inputField
                    fieldName="genesis__Account__c"
                    aura:id="inputFieldAccountName"
                    class="input-is-required"
                    onchange="{!c.lookupChange}"
                    value="{!v.accountId}"
                    autocomplete="nope"
                  />
                  <aura:set attribute="else">
                    <lightning:inputField
                      fieldName="genesis__Business_Name__c"
                      aura:id="inputFieldAccountId"
                      class="input-is-required"
                      autocomplete="nope2"
                    />
                  </aura:set>
                </aura:if>
              </aura:if>
              <aura:if

Helper:

 var inputAccountName = component.find("inputFieldAccountName");
 console.log(inputAccountName.get("v.value"));

gets exception on var input account name but just stops running at that point

 
Hi, 
I try have a wrapper like this (JSON)
public class myWrapper {

public String name;
public cls_status status;

class cls_status {
        public Integer id;	//0
        public String value;	//string
        public String href;	//string
    }
If i want to fill name, i can do
myWrapper resWrap = new myWrapper();
resWrap.name= 'David';

 But how can i fill value of status ? resWrap.status.value doesn't work.

Ty for help :)

I am running into cpu limit with this am I am missing somthing? And also how can I adjust the code to avoid harcoding the ID like i did.
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted ) {
               Database.LeadConvert lc = new Database.LeadConvert();
            
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(TRUE); 
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
                String leadOwner = lead.OwnerId;
              if(leadOwner.startsWith('00G')){
               Lc.OwnerId = '00535000001ZOZN'; }
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}

 
I have a requirement where CustomerSuccess__c field on opportunity to be updated  'true' if CustomerSuccess__c field on Account is 'true' in before Insert event.

I have tried below solution, trigger saved succesfully but it didn't work.
Can anyone explain why my trigger is not working
trigger OppoCustomerSuccessCheckboxUpdate on Opportunity (before insert) 
{
for(Opportunity opp : Trigger.New)
{
	if(Opp.AccountID != null)
	{
		if(Opp.Account.CustomerSuccess__c)
		{
			Opp.CustomerSuccess__c = true;
		}
	}
}
}
Regards,
Akash
 
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.