• Abhimanyu
  • NEWBIE
  • 65 Points
  • Member since 2016
  • TEKSystems


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 20
    Replies
Working in Lightning...I am trying to add a flow URL to a lightning component. Here is what I have entered:
<div aura:id="container">
    <p><lightning:formattedUrl value="https://promnetwork--hd2sf--c.cs27.visual.force.com/flow/runtime.apexp?flowDevName=Security_Exception_Request&flowVersionId=301220000001I27"/></p>
    </div>

When I try to save the component, I get this error:
Failed to save HDFlowLauncher.cmp: c:HDFlowLauncher:22,2: ParseError at [row,col]:[23,2] Message: The markup in the document following the root element must be well-formed.: Source

This is a URL...I can't edit it and have it still work. I entered this as a Lightning Configured URL so i can't sort out the problem.

Any suggestions out there?
Thanks much,
Steve
global class MonPipelineReportBatch implements Database.Batchable<sObject> {
    public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, Name, Phone, Starting_Credit_Score__c, ' 
                          +  'Status, Enrolled_On__c, Est_Re_Pull_Date__c, Realtor_Name__c ' 
                          +   ' FROM Lead';
    public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1];

    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date startDate = Date.today().addMonths(-1);
        startDate = Date.newInstance(startDate.year(),startDate.month(),1);
        Date endDate = startDate;
        Integer days = Date.daysInMonth(endDate.year(), endDate.month());
        endDate = Date.newInstance(startDate.year(),startDate.month(),days);

        query += ' WHERE CreatedDate >=: ' + startDate + ' AND CreatedDate <=: ' + endDate + ' AND Loan_Officer_1a__c != null';
        return Database.getQueryLocator(query);
    }

 
Requirement: I have 2 objects "Contact" and a custom object "OrderApi__Subscription__c". When the custom object record is inserted/updated, I want to update the certain information present on custom object record on Contact object when a lookup field on custom object = 'ABC'

Below is the trigger I wrote which is not giving me any error, but it is not updating the fields on contact

trigger updateContact on OrderApi__Subscription__c (after insert, after update) {

    Set<String> contactIds = new Set<String>();
    List<Contact> conupdateList = new List<Contact>();
    Integer count = 0;
    
    for(OrderApi__Subscription__c sub: Trigger.new) {
    contactIds.add(sub.OrderApi__Contact__c);
    }
    
    List<Contact> contactList = [Select id, Chapter_Member_Status__c, Chapter_Member_Activated_Date__c, Member_Paid_Through_Date__c, Member_Term_End_Date__c, Member_Term_Start_Date__c from Contact where id IN : contactIds];
    
    List<OrderApi__Subscription__c> subList = [Select id, OrderApi__Status__c , OrderApi__Item__c , OrderApi__Item__r.Name, OrderApi__Activated_Date__c, OrderApi__Paid_Through_Date__c, OrderApi__Current_Term_Start_Date__c, OrderApi__Current_Term_End_Date__c from OrderApi__Subscription__c where id IN: contactIds];
    
    List<Contact> contactList2 = new List<Contact>();
    for(OrderApi__Subscription__c sub: subList) {
    if(sub.OrderApi__Item__r.Name == 'ABC') {
    count++;
    }
    }
    
    for(Contact con:contactList) {
    OrderApi__Subscription__c membership = new OrderApi__Subscription__c();
    con.Chapter_Member_Status__c = membership.OrderApi__Status__c;
    String activatedDate = string.valueof(membership.OrderApi__Activated_Date__c);
    con.Chapter_Member_Activated_Date__c = activatedDate;
    String paidThroughDate = string.valueof(membership.OrderApi__Paid_Through_Date__c);
    con.Member_Paid_Through_Date__c = paidThroughDate;
    String termEndDate = string.valueof(membership.OrderApi__Current_Term_End_Date__c);
    con.Member_Term_End_Date__c = termEndDate;
    String termStartDate = string.valueof(membership.OrderApi__Current_Term_Start_Date__c);
    con.Member_Term_Start_Date__c = termStartDate;
    contactList2.add(con);
    }
    
    if(count > 0) {
    update contactList2;
    }   
}

 
Hi,
I wrote an apex batch which helps to delete reports in the Public Folder that haven't been run for more than 60 days.

When I test it in the Dev Console, I get an error such as "Too many callouts: 101".

How can I improve the code to overcome this issue?

Thanks for the help.
 
global class DeleteOldReportsBatch implements Database.Batchable<sObject>, Database.AllowsCallouts {

    //Get the records to be deleted
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'select id, FolderName from Report where LastRunDate <= LAST_N_DAYS:60';
        return Database.getQueryLocator(query);        
    }

    //Executes the deletion logic for reports records
    global void execute(Database.BatchableContext BC, List<Report> scope) {
    String url;

    for(Report r : scope) {
        if (r.FolderName == 'Public Reports'){        
            Http h = new Http();
            url = '/services/data/v44.0/analytics/reports/' + r.Id;
            System.debug(LoggingLevel.INFO, '*** url: ' + url);          

            HttpRequest req = new HttpRequest();

            req.setHeader('Authorization', 'Bearer '+ UserInfo.getSessionId());
            req.setMethod('DELETE');
            req.setEndpoint(url);

            HttpResponse res = h.send(req);
            System.debug(LoggingLevel.INFO, '*** rest: ' + res.getBody());
        }
        } 
    }

    global void finish(Database.BatchableContext BC) {}
}

 
Hi Team,

I have a requirement where the new case should not be created if field A(Contact ID lookup field) & field B(custom text field) combination already exists.
Is this possible to achieve the requirement using validation rule?

I know for a fact that as on date, VLOOKUP cannot be used on standard objects.

Any constructive suggestions are much appreciated!

Thanks!
Working in Lightning...I am trying to add a flow URL to a lightning component. Here is what I have entered:
<div aura:id="container">
    <p><lightning:formattedUrl value="https://promnetwork--hd2sf--c.cs27.visual.force.com/flow/runtime.apexp?flowDevName=Security_Exception_Request&flowVersionId=301220000001I27"/></p>
    </div>

When I try to save the component, I get this error:
Failed to save HDFlowLauncher.cmp: c:HDFlowLauncher:22,2: ParseError at [row,col]:[23,2] Message: The markup in the document following the root element must be well-formed.: Source

This is a URL...I can't edit it and have it still work. I entered this as a Lightning Configured URL so i can't sort out the problem.

Any suggestions out there?
Thanks much,
Steve
public class SearchLienController {
    
    
    @AuraEnabled 
    public static List<Lien__c> getLiens(String lienReservationNumber,String paymentConfirmationNumber,String lienClaimantName,String injuredWorkerName, String caseRefNumber) {
        
       
       String finalQry = finalQuery(lienReservationNumber, paymentConfirmationNumber, lienClaimantName, injuredWorkerName, caseRefNumber);
            
        return [SELECT Name,Case__r.CaseNumber,Lien_Claimant_Name__r.Name,Injured_Worker_Name__r.Name,Lien_Disposition__c,Form_Received_Date_Original_File_Date__c,Payment_Confirmation_Number__c,Total_Requested_Amount__c
                FROM Lien__c where =:finalQry];
    }
    
    private static String finalQuery(String lienReservationNumber,String paymentConfirmationNumber,String lienClaimantName,String injuredWorkerName, String caseRefNumber){
      
        String finalQry = '';
        String payCA = paymentConfirmationNumber;
        if(!String.isBlank(lienReservationNumber)){
            finalQry= ' Name=:lienReservationNumber';
        }
        
         if(!String.isBlank(payCA)){
               finalQry += ' AND Payment_Confirmation_Number__c=:payCA';  
          }
        
         if(!String.isBlank(lienClaimantName)){
               finalQry += ' AND Lien_Claimant_Name__r.id=:lienClaimantName';  
        }
        
         if(!String.isBlank(injuredWorkerName)){
               finalQry += ' AND Injured_Worker_Name__r.id=:injuredWorkerName';  
        }
        
         if(!String.isBlank(caseRefNumber)){
               finalQry += ' AND Case__r.CaseNumber=:caseRefNumber';  
        }

        if(finalQry.startsWith('AND')){
            finalQry = finalQry.replaceFirst('AND', '');
        } 
        
        return finalQry;

}
}
Hi,

My requirement is when ever we enter Last_Month__c  = June then we should able to enter Amount values upto June Month only. If we
try to enter July month to till December then that it should throw an error.

Note - There is a field called Starting_month__c so we enter a valuein that field for idea purpose when will be the starting month.

Last_Month__c is Picklist field and January , February, so on fields data type = 'Number'.

This sceniero is possible through validation rule or workflow or Process builder or trigger.

Please Suggest.

Thanks,
Chirag verma.
Hi everyone!
I took the code of this example and added my api key.
my page can call the jquery library but the google library can not,
Is it because of the pixels? I'm using 1080p screen but in the css i put 250px
https://salesforce.stackexchange.com/questions/146154/how-to-get-the-address-on-clicking-in-the-google-map
User-added image
<apex:page standardController="Account" > 
    <script  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBjHETKBAuSy2JcXUdg6itU3nYFze4W_eU&callback=initMap"> </script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>    
    <style>
        #map {
          font-family: Arial;
          font-size:12px;
          line-height:normal !important;
          height:250px;
          background:transparent;
        }
    </style>    
    <apex:form id="accountform" >
        <apex:pageBlock id="accountblock">
            <apex:pageBlockSection title="Account details">
                <apex:outputField Value="{!Account.Name}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="addressblocksection" title="Address details" columns="2">
                <apex:inputField id="BillingStreet" value="{!Account.BillingStreet}" />
                <apex:inputField id="BillingCity" value="{!Account.BillingCity}" />
                <apex:inputField id="BillingState" value="{!Account.BillingState}" />
                <apex:inputField id="BillingPostalCode" value="{!Account.BillingPostalCode}" />
                <apex:inputField id="BillingCountry" value="{!Account.BillingCountry}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
        <div id="map">Hello</div> 
        <script type="text/javascript">
            $(document).ready(function() {
                var map;
                var marker;             
                var myOptions = {
                    zoom: 15,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    mapTypeControl: false
                }                
                var geocoder = new google.maps.Geocoder();
                var address = "{!JSENCODE(Account.BillingStreet)}, " + "{!JSENCODE(Account.BillingCity)}, " + "{!JSENCODE(Account.BillingPostalCode)}, " + "{!JSENCODE(Account.BillingCountry)}";
                address = address.replace(/(\r\n|\n|\r)/gm,"");
                geocoder.geocode( { address: address}, function(results, status) {
                    if (status == google.maps.GeocoderStatus.OK && results.length) {
                        if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
                            //create map
                            map = new google.maps.Map(document.getElementById("map"), myOptions);
                            //center map
                            map.setCenter(results[0].geometry.location);
                            //create marker
                            marker = new google.maps.Marker({
                                position: results[0].geometry.location,
                                map: map,
                                title: "{!Account.Name}"
                            });
                            //add listeners
                            google.maps.event.addListener(map, 'click', function(event) {
                              geocoder.geocode({'latLng': event.latLng},function(results, status){
                                  if (status == google.maps.GeocoderStatus.OK && results.length) {
                                      result=results[0].address_components;
                                      var info=[];
                                      for(var i=0;i<result.length;++i){
                                        if(result[i].types[0]=="street_number"){
                                            info.push(result[i].long_name);
                                        }
                                        if(result[i].types[0]=="route"){
                                            info.push(result[i].long_name);
                                            document.getElementById('{!$Component.accountform.accountblock.addressblocksection.BillingStreet}').value = info.join(' ');
                                        }
                                        if(result[i].types[0]=="locality"){
                                            document.getElementById('{!$Component.accountform.accountblock.addressblocksection.BillingCity}').value = result[i].long_name;
                                        }
                                        if(result[i].types[0]=="administrative_area_level_1"){
                                            document.getElementById('{!$Component.accountform.accountblock.addressblocksection.BillingState}').value = result[i].long_name;
                                        }
                                        if(result[i].types[0]=="country"){
                                            document.getElementById('{!$Component.accountform.accountblock.addressblocksection.BillingCountry}').value = result[i].long_name;
                                        }
                                        if(result[i].types[0]=="postal_code"){
                                            document.getElementById('{!$Component.accountform.accountblock.addressblocksection.BillingPostalCode}').value = result[i].long_name;
                                        }                                       
                                      }
                                  }
                              });
                            });                         
                        }
                    }else{
                        $('#map').css({'height' : '15px'});
                        $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
                    }
                });
            });
        </script>
    </apex:form>
</apex:page>

 
global class MonPipelineReportBatch implements Database.Batchable<sObject> {
    public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, Name, Phone, Starting_Credit_Score__c, ' 
                          +  'Status, Enrolled_On__c, Est_Re_Pull_Date__c, Realtor_Name__c ' 
                          +   ' FROM Lead';
    public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1];

    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date startDate = Date.today().addMonths(-1);
        startDate = Date.newInstance(startDate.year(),startDate.month(),1);
        Date endDate = startDate;
        Integer days = Date.daysInMonth(endDate.year(), endDate.month());
        endDate = Date.newInstance(startDate.year(),startDate.month(),days);

        query += ' WHERE CreatedDate >=: ' + startDate + ' AND CreatedDate <=: ' + endDate + ' AND Loan_Officer_1a__c != null';
        return Database.getQueryLocator(query);
    }