• balraj singh 33
  • NEWBIE
  • 75 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 14
    Replies
I am trying to find field value by using aura:id but i am getting an error as 
component.find("aura:id") is giving undefined.


Here i my component : 

<lightning:recordEditForm  aura:id="form" recordId="{!v.recordId}" objectApiName="Contact" density="compact" 
                              onsuccess="{!c.handleSuccess}" onerror="{!c.handleError}" onsubmit="{! c.handleSave }" >
        <!-- <aura:if isTrue="{!v.isEditPage}">
            <lightning:messages />
        </aura:if>-->
        
        <!--Detail Panel-->
        
        <lightning:accordion aura:id="accordion" activeSectionName="{!v.activeSections}" allowMultipleSectionsOpen="true">
            
            <!--Detail Section-->               
            <lightning:accordionSection name="A" label="Detail">            
                <aura:set attribute="actions">
                    <aura:if isTrue="{!v.isEditPage}">
                        <lightning:buttonIcon iconName="utility:save" variant="bare" alternativeText="" type="submit" />
                        <aura:set attribute="else">
                            <lightning:buttonIcon iconName="utility:edit" variant="bare" onclick="{! c.changeEditLayout }"
                                                  alternativeText="Edit" />
                        </aura:set>
                    </aura:if>
                </aura:set>
                <ui:scrollerWrapper class="scrollerSize">
                    <div class="slds-grid slds-gutters slds-wrap">
                        
                        <!-- LEFT COLOUMN DETAIL-->
                        
                        <div class="slds-col slds-size_1-of-1 slds-large-size_6-of-12">
                            <!--div class="slds-col slds-size_6-of-12"-->
                            
                            <div class="slds-border_bottom">
                                <aura:if isTrue="{!v.isEditPage}">
                                    <lightning:inputField aura:id="FirstName" value="{!v.FirstName}"
                                                          fieldName="FirstName" 
                                                          required="true"/>
                                    <lightning:inputField aura:id="LastName" value="{!v.LastName}"
                                                          fieldName="LastName" />
                                    <!-- <lightning:inputName aura:id="myname" label="Full Name" firstName="{!v.FirstName}"
                                                         lastName="{!v.LastName}"
                                                         fieldsToDisplay="{!v.fields}" required="true" /> -->
                                    <aura:set attribute="else">
                                        <lightning:outputField aura:id="Name1" value="{!v.Name}" fieldName="Name" />
                                    </aura:set>
                                </aura:if>
                            </div>
              <div class="slds-border_bottom">
                                <aura:if isTrue="{!v.RFSet}">
                                    <lightning:outputField aura:id="Current_Firm__c" value="{!v.Current_Firm__c}"
                                                           fieldName="Current_Firm__c" />
                                </aura:if>
                                <aura:if isTrue="{!not(v.RFSet)}">
                                    <aura:if isTrue="{!v.isEditPage}">
                                        <lightning:inputField aura:id="Current_Firm__c1" value="{!v.Current_Firm__c}"
                                                              fieldName="Current_Firm__c" onchange="{!c.handleChange}"/>
                                        <aura:set attribute="else">
                                            <lightning:outputField aura:id="Current_Firm__c2" value="{!v.Current_Firm__c}"
                                                                   fieldName="Current_Firm__c" />
                                        </aura:set>
                                    </aura:if>
                                </aura:if>
                            </div>
Controller : 

handleChange : function(component, event, helper) {
        console.log( "inside handleCurrentFirmChange");        
    
     var fNameAttValue = component.Find("FirstName");
        
        console.log('First Name : ' +fNameAttValue);
I cannot read value using document.getelementbyId , it gives me an error AddNote:44 Uncaught TypeError: Cannot read properties of null (reading 'value')

Here is my Code : 

<apex:page standardController="Opportunity" lightningStylesheets="true" extensions="AddNoteController">
    
    
    <script type="text/javascript">
        function CheckUrl() {
            console.log('I AM IN ');
            
            var text = document.getElementById("{!$Component.div1.theform.thePageBlock.thePageBlockitem.test}").value;
            
            if(new RegExp("([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?").test(string1)) {
                alert("Url is present in this statement");
                 console.log('I AM IN IF OF THE CALL');
            }
            else {
                console.log('I AM IN ELSE OF THE CALL');
                savenote1();
                
            }
        }
    </script>
    
    <div class="slds-scope" id="div1">
        
        <apex:form  id="theform">
            <apex:pageBlock >
                <apex:pageBlockSection  id="thePageBlock">
                    <apex:pageBlockSectionItem id="thePageBlockitem" >
                        <apex:inputTextarea id="test" value="{!notes}" style="height:150px; width:200px"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:commandButton value="Save" onclick="CheckUrl();return false;"/> 
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:pageBlock>
            
            <apex:actionFunction id="savenote" name="savenote1" action="{!saveNote}"></apex:actionFunction>
        </apex:form>
        
    </div>
    
</apex:page>
SOAP API upsert is not working for newly created field in salesforce whereas if i thry to update or insert it works.

The new field that was created, its a picklist field. Strangely this field is not being updated whenever Bhoomi tries to upsert Account, but other fields gets updated in the same transaction but not this field. 
Commands used :

A)sfdx force:package:create --name "XYZ" --description "Understand" --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername hub
B) Create a Package Version
* sfdx force:package:version:create -p "XYZ" -d force-app --wait 10 -k l1b3rtY --codecoverage --releasenotesurl "http://example.com" --postinstallurl " http://example.com -v hub

C) Promote the package
* sfdx force:package:version:promote -p " XYZ @<<version>>" -v hub


We i try to promote the package but it fails

reason it shows is low code coverage and if we check code coverage of the package version it is only 12 percent.

but , we are creating package version using codecoverage parameter and it gives no error , also the when we deploy the package there are no issues.
Pcakage has only two apex classes and test class for then and all other are custom fields.
 
Package Version creation is failing is SDFX CLI.
 How would I add this currency as part of the test data in test class?

My understanding is , as part of package creation salesforce creates an empty scratch org and deploy the metadata and finally run the test classes. By default only 'USD' is available in empty scratch org. The above test method is failing since "EUR" currency is not available.

Test class uses code which has 
demoNewquote.CurrencyIsoCode = 'EUR';
Some Test classes are failing in salesforce CLI , but they run successfully in UI or dev console.

Command :

sfdx force:apex:test:run --testlevel RunLocalTests --codecoverage --resultformat human --wait 30 -u $org_username


Error : Outcome: Fail Message: Your request exceeded the time limit for processing. connection was cancelled here Runtime

Also Test classes failed have ".null" appened after the name in report , not sure why.
i am having issues with openid connect configurations, which i looked into and is handled
 but now  i am getting error: AuthorizationError?Err[…]orDescription=No+response&ProviderId=0SO040000004CCq

Also i do not get issue when they try in incognito window
any suggestion please
 
I have below VF page which has lightening components in it :
I is giving error while loading for FSL:optInsightHealthCheck . Error message 'No 'Access-Control-Allow-Origin' header is present on the requested resource.'
<apex:page standardController="FSL__Optimization_Request__c"> <apex:includeLightning /> <br /> <div> <table > <tr> <td valign="top"> <div id="optimizationInsightsMetrics" /> <br /> <div id="optimizationInsightsKPIs" /> </td> <td valign="top"> <div id="optimizationInsightsSummary"/> <br /> <div id="optInsightHealthCheck" /> </td> </tr> </table> </div> <script> $Lightning.use("c:OptimizationInsightsAura", function() { $Lightning.createComponent("FSL:optimizationInsightsKPIs", { recordId : '{!$CurrentPage.parameters.Id}',label : "KPI" }, "optimizationInsightsKPIs", function(cmp) { } ); $Lightning.createComponent("FSL:optimizationInsightsMetrics", { recordId : '{!$CurrentPage.parameters.Id}',label : "Metrics" }, "optimizationInsightsMetrics", function(cmp) { } ); $Lightning.createComponent("FSL:optimizationInsightsSummary", { recordId : '{!$CurrentPage.parameters.Id}',label : "Summary" }, "optimizationInsightsSummary", function(cmp) { } ); $Lightning.createComponent("FSL:optInsightHealthCheck", { recordId : '{!$CurrentPage.parameters.Id}',label : "Health Check" }, "optInsightHealthCheck", function(cmp) { } ); }); </script> </apex:page>
<apex:outputPanel rendered="

{!NOT(ISPICKVAL($User.UserType,'Guest')) }">

<script> window.location.href = "./"; </script> </apex:outputPanel>
 date formating using Outputtext is not displayinfg the correct date 
it is converting Mon Dec 30 00:00:00 GMT 2019
to 12/30/2020 whereas it should be 12/30/2019

Using the below expression 
<apex:outputText value="{0,date,MM/dd/YYYY}"> <apex:param value="{!mydate.CreatedDate}" /> </apex:outputText>
The inputfield is not displaying calender year it displays only month :

Code:
<div class="slds-form-element"> <label class="slds-form-element__label" for="DOBID">Date of Birth: </label> <div class="slds-form-element__control"> <apex:inputfield styleClass="slds-input" id="DOBID" value="{!sboject.myfield__c}" taborderhint="32"/> </div> </div>
User-added image
i am trying to deactivate the users and send and email for the same , but i am getting the error.Please suggest 

Try{
            
            update Userdeactivated;
            system.debug(Userdeactivated);
            sendemailalert(Userdeactivated);
           
        }
        Catch(Exception e){
            System.debug(e);
        }
        
 }
    Public void sendemailalert(list<user> userr) {
        Integer i =1;
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        List<String> ToAddress = new List<String>();
      
        String[] finalemail = a.email__c.split(','); 
        
        
        system.debug(finalemail.size());
        for(Integer p = finalemail.size();p>0;p--){
            
            Toaddress.add(finalemail[p-1]);

            }
        message.setToAddresses(Toaddress);
        
        message.subject = 'Notification for the users deactivated  Today';
         String plainTextBody = 'List of the Users deactivated due to 90 days of inactivity: ';
                              
        for(Integer n = userr.size();n>0;n--){
               
              plainTextBody += '\n'+i+')Name: '+userr[n-1].name+ ' ,UserName: '+userr[n-1].username+' \n';
               i++;
               system.debug(userr[n-1].name);
               system.debug(userr[n-1].username);
        }
         message.setplainTextBody(plainTextBody);
         
         Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};

         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);

         if (results[0].success) {

         System.debug('The email was sent successfully.');

         } 
         else {

             System.debug('The email failed to send: ' + results[0].errors[0].message);

         

}
 
String plainTextBody = 'The below Users are deactivated due 90 days of inactivity \n';
        
        
        for(Integer n = userr.size();n>0;n--){
               
               plainTextBody += i+')'+userr[n-1].name+'\n';
               i++;
               system.debug(+userr[n-1].name);
               system.debug(userr[n-1].username);
        }
         message.setplainTextBody(plainTextBody);
list<id> accountids;
for(contact con1 : [select id,accountid From contact where lastname = 'TEST'and birthdate = 2019-04-15 and firstname = 'TEST'])

{
   system.debug(con1.accountid);
      
}

system.debug(accountids);
 
<apex:outputPanel id="NewAssessmentscreen">
        <script type="text/javascript">
        function setViewAndEditLink()
{
$("a.actionLink[data-status='Entered in Error'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Incomplete'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Not Eligible'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Discharged'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Continued'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-showDischarge='false'][data-button='Discharge DST']").hide();
$("a.actionLink[data-type='DST'][data-showContinued='false'][data-button='Continue DST']").hide();
$("a.actionLink[data-type='DST'][data-showEdit='false'][data-button='Edit']").hide();
/*End*/
//DE87019-UAT : Related List needs formatting fixes /*Start*/
$("a.actionLink[data-button='Edit']").addClass('setBorder');
/*End*/
$("a.actionLink[data-type='Assessment'][data-status='Incomplete'][data-button='Edit']").hide();
$("a.actionLink[data-type='Assessment'][data-status='Completed'][data-esignCheck ='false'][data-button='Edit']").hide();
$("a.actionLink[data-type='Assessment'][data-status='Completed'][data-appStatus ='Approved'][data-esignCheck ='true'][data-button='Edit']").hide();

/*
101 SOQL ERROR REMEDY
if('{!JSENCODE(ProfileName)}' == '{!JSENCODE(ClinicalSupportProfile)}')
*/
//START: DE132997- Clinical Indicators:  Continuing an existing assessment does not save change in answers
$("a.actionLink[data-type='Clinical Indicators'][data-esignCheck ='false'][data-status='Completed'][data-button='Edit']").hide();
$("a.actionLink[data-type='Clinical Indicators'][data-status='Completed'][data-appStatus ='Approved'][data-esignCheck ='true'][data-button='Edit']").hide();
if('{!$Profile.Name}' == '{!JSENCODE(ClinicalSupportProfile)}')
{
$("a.actionLink[data-esignCheck ='true'][data-appStatus='Pending Approval'][data-button='Edit']").hide();
}
$("a.actionLink[data-type='Fall Risk'][data-status='Completed'][data-button='Edit']").hide();
//US713529 : Add Discharge Planning & Instructions to SOAP under Discharge Planning
$("a.actionLink[data-type='Discharge'][data-status='Completed'][data-button='Edit']").hide();
//US713529  ends
//US618562  Add MRA Assessment to SOAP note - Assessment Tab
$("a.actionLink[data-type='Mortality Risk'][data-status='Completed'][data-button='Edit']").hide();
//Bug-Id : 326 /*Start*/
var isPortalUserJS = '{!JSENCODE(IF(isPortalUser,"true","false"))}';
if(isPortalUserJS=='true'){
$("a.actionLink[data-button='Edit']").hide();
}
}
 
<div class="slds-size--1-of-1 slds-grid slds-wrap">
                                        <div class="slds-col--padded slds-size--1-of-2  slds-m-top--small">
                                            <span class="colorRed">* </span><label class="slds-form-element__label" for="GUTOA">Update Date</label>
                                            <div class="slds-form-element__control slds-input-has-icon">
                                                <apex:inputtext value="{!ifUpDate}" html-data-rule-required="true" id="ifUpDate" styleClass="slds-input ifUpDate"/>
                                                <apex:image id="calendarImgUp" styleClass="absolute-calendar" value="{!$Resource.calendar_icon}" height="25px" width="27px" onmouseover="fnInitCalendar(this, '{!$Component.ifUpDate}', 'close=true')" />
                                            </div>
                                        </div>
 
<apex:page standardcontroller="quote" extensions="quotequery" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true" >
    <apex:pageBlock title="Export Results" >
        <apex:pageBlockTable value="{!cs}" var="quote">
            <apex:column value="{!quote.ID}"/>
            <apex:column value="{!quote.Name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
Some Test classes are failing in salesforce CLI , but they run successfully in UI or dev console.

Command :

sfdx force:apex:test:run --testlevel RunLocalTests --codecoverage --resultformat human --wait 30 -u $org_username


Error : Outcome: Fail Message: Your request exceeded the time limit for processing. connection was cancelled here Runtime

Also Test classes failed have ".null" appened after the name in report , not sure why.
 date formating using Outputtext is not displayinfg the correct date 
it is converting Mon Dec 30 00:00:00 GMT 2019
to 12/30/2020 whereas it should be 12/30/2019

Using the below expression 
<apex:outputText value="{0,date,MM/dd/YYYY}"> <apex:param value="{!mydate.CreatedDate}" /> </apex:outputText>
<div class="slds-size--1-of-1 slds-grid slds-wrap">
                                        <div class="slds-col--padded slds-size--1-of-2  slds-m-top--small">
                                            <span class="colorRed">* </span><label class="slds-form-element__label" for="GUTOA">Update Date</label>
                                            <div class="slds-form-element__control slds-input-has-icon">
                                                <apex:inputtext value="{!ifUpDate}" html-data-rule-required="true" id="ifUpDate" styleClass="slds-input ifUpDate"/>
                                                <apex:image id="calendarImgUp" styleClass="absolute-calendar" value="{!$Resource.calendar_icon}" height="25px" width="27px" onmouseover="fnInitCalendar(this, '{!$Component.ifUpDate}', 'close=true')" />
                                            </div>
                                        </div>
 
public class assignment {
    public list<account>var;
    public string var2{get;set;}   

 public void mymethod()
    {
        system.debug(vAR2);
        If(var2!=nULL)
        {
            List<List<SObject>> searchList= [find :var2 in all fields RETURNING account(name,id)];
            var = searchlist[0];        }
        else{
               
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter ant keyword'));
        
        }



page:

<apex:inputtext value="{!var2}"/>
    <apex:commandbutton value="Search" action="{!mymethod}" rerender="B"></apex:commandbutton>
MY VISUALFORCE PAGE CONATINS
<apex:pageblocktable value="{!var21}" var="a" ID="B">
                <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" assignTo="{!idvariable}"></apex:param>

                    </apex:commandlink>
                </apex:column>
                 <apex:column value="{!a.name}"/>
             </apex:pageblocktable>

MY CONTROLLER APEX:

 public string idvariable{get;set;}  

 public pagereference editaccount()
    {
        PageReference newPage = new PageReference('/'+idvariable+'/e');

  newPage.setRedirect(true);

  return newPage;
    }
String sch1 = '0 0/10 * 1/1 * ? *';
System.schedule('Scheduled Job 3', sch1, new myScheduleClass());

I generated the cron expression using tool cronmaker.

ERROR:System.StringException: Seconds and minutes must be specified as integers: 0 0/10 * 1/1 * ? *
i am getting the error when i try to insert multiple records from data loader. It is working for single record.
User-added image