• Alejandro Braunschweig
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

Hello everyone, good day.

I have an issue I have not been able to resolve; it involves the "lightning-input-field component", which according to the specification supports the "focus()" method.

I have been unable to achieve such simple thing under the following scenario: LWC comprised of: modal window -> lightning-record-edit-form -> list of lightning-input-field

Said list is dynamically creaed by:

<template for:each={newFields} for:item="field">
    <div class="half-view" key={field.name}>
        <lightning-input-field field-name={field.name} name={field.name}></lightning-input-field>
        <span class="fieldMessageStyle">{field.message}</span>
    </div>
</template>

My attempt to invoke the method simply does nothing; I mean it, no errors, no warnings, the focus stays where it is, i.e. it does not get sent anywhere else.

this.template.querySelector('lightning-input-field.slds-form-element.slds-form-element_stacked[c-lwc-lwc]').focus();

(I just want to target the first item in the list).

I have place a static lightning-combobox in the same modal using the same html node structure, and it does recieve the focus when invoked:

this.template.querySelector('lightning-combobox[c-lwc-lwc]').focus(); 

I could find in the documentation anything pointing to this "control" ignoring its focus method if dynamically created. Anyone know how to get around this?

Thank you all for your time and interest.

Hello everyone, good day.

I have an issue I have not been able to resolve; it involves the "lightning-input-field component", which according to the specification supports the "focus()" method.

I have been unable to achieve such simple thing under the following scenario: LWC comprised of: modal window -> lightning-record-edit-form -> list of lightning-input-field

Said list is dynamically creaed by:

<template for:each={newFields} for:item="field">
    <div class="half-view" key={field.name}>
        <lightning-input-field field-name={field.name} name={field.name}></lightning-input-field>
        <span class="fieldMessageStyle">{field.message}</span>
    </div>
</template>

My attempt to invoke the method simply does nothing; I mean it, no errors, no warnings, the focus stays where it is, i.e. it does not get sent anywhere else.

this.template.querySelector('lightning-input-field.slds-form-element.slds-form-element_stacked[c-lwc-lwc]').focus();

(I just want to target the first item in the list).

I have place a static lightning-combobox in the same modal using the same html node structure, and it does recieve the focus when invoked:

this.template.querySelector('lightning-combobox[c-lwc-lwc]').focus(); 

I could find in the documentation anything pointing to this "control" ignoring its focus method if dynamically created. Anyone know how to get around this?

Thank you all for your time and interest.

Hi,
I am getting "System.LimitException: Too many SOQL queries: 101" from belo test class, please help me to reslove this isse.
----------------------------------------------------------------------------------------------
@isTest
public class OpportunityProductTriggerTest {
    
        private static Map<String, Id> getRecordTypes() {
        Map<String, Id> recordTypeByName = new Map<String, Id>();
        List<RecordType> rts = [select id,developerName from RecordType];
        system.debug(rts);
        for(RecordType r: rts) {
            recordTypeByName.put(r.developerName, r.Id);
        }
       
            return recordTypeByName;
        }
    
        @isTest static void TestInsert() {
      
        Map<String, Id> rts = getRecordTypes();
        Product2 p = TestDataFactory.createProduct('Test', 'Goods', 'Food goods', 'Fixed Amount', true);
        p.CPM_applicable__c = true;
        p.IsActive = true;
  //      p.RevenueRecognition__c = 'POC Cost';
        insert p;

        Id pbId = Test.getStandardPricebookId();
        PriceBookEntry pb = TestDataFactory.creatPriceBook(p.Id, 10, true, pbId);
        insert pb;

        SYSTEM.debug('== ' + rts.keySet());
        Account company = TestDataFactory.createAccount('Au_feminin','test1@gmail.com', 'France', 'Paris', 'Street', 'France', 'Paris', 'Paris street', 'LUX-TVA', '2211', rts.get('Company'));
        insert company;

        Account acc = TestDataFactory.createAccount('Apple','test2@gmail.com', 'Belgium', 'Liege', 'Street', 'Belgium', 'Liege', 'street', 'LUX-TVA', '223', rts.get('Annonceur'));
        insert acc;

        Opportunity opp = TestDataFactory.createOpportunity('Test', 'Qualification', Date.today(), company.Id, acc.Id, null, 'CW8_AGENT_TYPE-1',rts.get('Default'), 'No', 'CUSTOMER_CONTRACT_TYPE-2');
        opp.Probability = 4;
        insert opp;

        OpportunityLineItem lineItem1 = new OpportunityLineItem (OpportunityID=opp.id,
                                                                 //PriceBookEntryID=pbe1.id, 
                                                                 PriceBookEntryID=pb.id, 
                                                                 //fatima
                                                                 Product2Id = p.id,
                                                                 ServiceDate = System.today() + 500,
                                                                 Realization_to_date__c = System.today() + 510,
                                                                 UnitPrice = 50,
                                                                 Contact_volume__c = 500,
                                                                 Quantity=1, 
                                                                 Cost_Center_Company__c = 'Alfemminile',
                                                                 Cost_Center__c = 'CC-ALF51',
                                                                 DeleteScheduleItem__c = true,
                                                                 Estimated_costs_copy_from_line_item_sche__c = 5
                                                                 
                                                                );

        insert lineItem1;

        system.debug('Foued_toto => ' + lineItem1.Id);
                    
            
        
        SetStaticVariable.AutomaticCreation = true;
            
        OpportunityLineItemSchedule olis = new OpportunityLineItemSchedule(ActualCosts__c = 100, EstimatedCost__c = 500, 
                                                                           OpportunityLineItemId = lineItem1.Id,
                                        Type='Revenue', Revenue = 200, ScheduleDate = System.today()+220,
                                        FromDate__c = system.today()+250, EndDate__c = system.today() + 880,
                                        Revenue_Recognition_Product__c = 'Custom');
        insert olis;
            
                        Billing_Schedule__c bil = new Billing_Schedule__c(
                                    Opportunity__c = opp.id,
                                    Amount__c = 20.5,
                                    Opportunity_Product_Id__c = lineItem1.Id,
                                    Start_Date__c = System.today() + 500,
                                     End_Date__c = System.today() + 510

            
                );              
            insert bil; 
            
            
            
                    Product2 p2 = TestDataFactory.createProduct('Test', 'Goods', 'Food goods', 'Fixed Amount', true);
        p2.CPM_applicable__c = true;
        p2.Volume__c = 700;
        p2.IsActive = true;
        insert p2;

        Id pbId2 = Test.getStandardPricebookId();
        PriceBookEntry pb2 = TestDataFactory.creatPriceBook(p2.Id, 10, true, pbId2);
        insert pb2;

        SYSTEM.debug('== ' + rts.keySet());
        

        Opportunity opp2 = TestDataFactory.createOpportunity('Test', 'Qualification', Date.today(), company.Id, acc.Id, null, 'CW8_AGENT_TYPE-1',rts.get('Default'), 'No', 'CUSTOMER_CONTRACT_TYPE-2');
        opp2.Probability = 4;
        insert opp2;

        OpportunityLineItem lineItem2 = new OpportunityLineItem (OpportunityID=opp2.id,
                                                                 //PriceBookEntryID=pbe1.id, 
                                                                 PriceBookEntryID=pb2.id, 
                                                                 //fatima
                                                                 Product2Id = p2.id,
                                                                 ServiceDate = System.today() + 500,
                                                                 Realization_to_date__c = System.today() + 510,
                                                                 UnitPrice = 50,
                                                                 Contact_volume__c = null,
                                                                 Quantity=1, 
                                                                 Cost_Center_Company__c = 'Alfemminile',
                                                                 Cost_Center__c = 'CC-ALF51',
                                                                 DeleteScheduleItem__c = true,
                                                                 Estimated_costs_copy_from_line_item_sche__c = 5
                                                                 
                                                                );

        insert lineItem2;
            lineItem2.UnitPrice = 8;
            lineItem2.Contact_volume__c = 500;
            lineItem2.Discount = 7;
            update lineItem2;
            
      //      lineItem2.UnitPrice = null;
            lineItem2.Quantity = null;
            lineItem2.TotalPrice = 5;
            update lineItem2;
            
            OpportunityLineItem lineItem3 = new OpportunityLineItem (OpportunityID=opp2.id,
                                                                 //PriceBookEntryID=pbe1.id, 
                                                                 PriceBookEntryID=pb2.id, 
                                                                 //fatima
                                                                 Product2Id = p2.id,
                                                                 ServiceDate = System.today() + 500,
                                                                 Realization_to_date__c = System.today() + 510,
                                                                 UnitPrice = null,
                                                                 Contact_volume__c = null,
                                                                 Quantity=1, 
                                                                 Cost_Center_Company__c = 'Alfemminile',
                                                                 Cost_Center__c = 'CC-ALF51',
                                                                 DeleteScheduleItem__c = true,
                                                                 Estimated_costs_copy_from_line_item_sche__c = 5
                                                                 
                                                                );

        insert lineItem3;
            
                    
        p.RevenueRecognition__c = 'POC Cost';
        update p;
           
        lineItem1.ServiceDate = System.Today() + 600;
        lineItem1.Realization_to_date__c = System.Today() + 610;
        lineItem1.UnitPrice = 20;
        lineItem1.Quantity = 7;
            
        update lineItem1;
            
        delete lineItem1;
        }
                

}
--------------------------------------------------------------------------------------------
I trying to test the Apex Call outs which uses the OAuth Authentication. I am not sure what I am missing here it throws error on the line HttpResponse res1 = http1.send(req1); like 

Line: 22, Column: 1
System.UnexpectedException: java.lang.IllegalArgumentException: invalid start or end
public class TestD365API {
    public final String clientId = 'xxxxxxxxxxxxx';
    public final String clientSecret = 'xxxxxxxx';
    
    public String getD365Customer(){             
        String reqbody = 'grant_type=client_credentials&client_id='+clientId+'&client_secret='+clientSecret;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setBody(reqbody);
        req.setMethod('POST');
        req.setEndpoint('https://login.microsoftonline.com/tenant/oauth2/token');
        HttpResponse res = h.send(req);
        deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
        String atoken = resp1.access_token;
        
        
        Http http1 = new Http();
        HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('https://dev-xyz/data/Customers');
        req1.setMethod('GET');
        req1.setHeader('Authorization','Bearer '+atoken);
        HttpResponse res1 = http1.send(req1);
        System.debug('Response Body=========' + res1.getBody());
        return res1.getBody();   
    }  
    
    public class deserializeResponse
    {
        public String token_type;
        public String expires_in;
        public String ext_expires_in;
        public String expires_on;
        public String not_before;
        public String resource;
        public String access_token;
    }
}
Please help me fixing this issue.
  • February 13, 2020
  • Like
  • 1
I am trying to make a RESTful callout containing a very long string (think: the body length of a typical informative email) as a parameter from Salesforce to Marketo. The callout succeeds when the string is shorter, but fails when the length increases. When I make the exact same callout using postman, it works as expected. Is there any limit on the length of the URL (or anything else) I am missing?

The long string contains the HTML body of an email to be sent out through Marketo, a Marketing tool.
Happy to provide details if needed.
  • November 06, 2015
  • Like
  • 0

All,

 

We have a button which takes the next case from a given queue, changes the owner to the logged in user and then displays the case to the customer service rep.

 

Now, if 2 customer service reps click the button simultaneously it can happen that they both get the case. Of course, only one of them acutually owns the case but they don't know that because it looks like they both own it (a refresh reveals the true owner).

 

We've tried locking the record using "for update" when fetching the case yet still it seems to be possible to end up with 2 different screens (on one screen the case is owned by user A and on the other it's owned by user B). Again, hitting F5 reveals the actual owner.

 

I was hoping that when trying to select for update I would get an exception which I could catch and from there do some error handling. However, it seems that either no exception is thrown or, if an exception is thrown, it isn't catchable.

 

Then I thought that maybe it would be possible to code my way out of it. E.g. using synchronized methods like in Java but it seems that is not yet possible in Apex (see http://forums.sforce.com/t5/Apex-Code-Development/quot-synchronized-quot-where-s-it-documented-Anyway-to-control/m-p/124811).

 

Has anyone else had a similar issue and if so, how was it solved (if it was solved...)?

 

Kind regards,

 

Søren Nødskov Hansen