• GulshanRaj
  • SMARTIE
  • 912 Points
  • Member since 2017
  • CRM Manager
  • ArganoKeste


  • Chatter
    Feed
  • 28
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 164
    Replies
We have various SMS Templates as a CustomMetaData and need to add mergeField on these Metadata records. This MergeField is the fieldData on the custom lead object to which the SMS should be sent. Is this possible to add MergeFields on a MetaData Text field.
Hello,
Will someone help me with how do I get the row field values when a user updates a field?
I want to take the value from an updates field and multiply it by a value from another field(same row) and take the calculated value and put it into another field(same row).
I just need the syntax for getting the field values of the row.
I need to get this resolved so any help is greatly appreciated.

  • February 05, 2022
  • Like
  • 0
Hi All,

How to hide Jquery (Input) button in visualforce page and need to display particular profile.

Thanks
KMK
  • January 30, 2022
  • Like
  • 0
I want to create a class object knowing only its name. This object belongs to Batch, but I don't know which one. So i have to run it by name only. i get error when i pass sObject to executeBatch.
 
@AuraEnabled
    public static void run(String batchName){
        sObject newObject = (sObject)Type.forName(batchName).newInstance();
        Database.executeBatch(newObject);
    }
How to bypass it.
Thanks in advance.

I am trying to update the value of my object elements whenever one of the object is deleted. However, I always get the Uncaught ReferenceError: i is not defined error on my console. 

Here is my code 

deleteTask(event) {

this.todoTasks = this.todoTasks.filter(task => task.id !== event.target.name);
this.updateId();
console.log(this.todoTasks);
}
updateId(){
for(i=1; i<=this.todoTasks.length; i++){
this.todoTasks[i-1].id = i;
}
}

Hi,
How can I create a  visualforce page that replicates the list view of my custom object records, and the functionality of being able to select a record and then use the action button to add a New Competitor to this record and to populate the record that I have selected. Please see below.

User-added image

User-added imageI have create numerous visualforce pages in an attempt to replicate this functionality (where the Division is pulled through to the form) but nothing seems to be working. The Division is the master and the Competitor is the child in the master-detail relationship of the field "Division".

Thanks
Hi Gurus,

Please provide me a test class for below look up class
 
/**
* Class used to serialize a single Lookup search result item
* The Lookup controller returns a List<LookupSearchResult> when sending search result back to Lightning
*/
public class LookupSearchResult {

    private Id id;
    private String sObjectType;
    private String icon;
    private String title;
    private String subtitle;

    public LookupSearchResult(Id id, String sObjectType, String icon, String title, String subtitle) {
        this.id = id;
        this.sObjectType = sObjectType;
        this.icon = icon;
        this.title = title;
        this.subtitle = subtitle;
    }

    @AuraEnabled
    public Id getId() {
        return id;
    }

    @AuraEnabled
    public String getSObjectType() {
        return sObjectType;
    }

    @AuraEnabled
    public String getIcon() {
        return icon;
    }

    @AuraEnabled
    public String getTitle() {
        return title;
    }

    @AuraEnabled
    public String getSubtitle() {
        return subtitle;
    }
}

Regards,
Fiona​​​​​​​
    @auraEnabled
    Public static List<string> invokeWebServiceString ssnumber) {
        String [] arrayOfResponsestrings = new List<String>();

        for(String num : ssnumber.split(',')){          
            ResponseWrapper APIResponse = InvokeAPI.invokeRespAPI(num);
            arrayOfResponsestrings.add(JSON.serialize(APIResponse ));
            System.debug('arrayOfResponsestrings :'+arrayOfResponsestrings);
        }
        for(Integer i=0 ;i<arrayOfResponsestrings.size() ; i++) {
        }
        return arrayOfResponsestrings;
    } 
  • September 30, 2018
  • Like
  • 0
The recordEditForm and recordViewForm, while not supported in Lightning Out, do work apart from two errors, neither of which appear to affect the functionality.

Is there any way of preventing these error from displaying so that we can use these components?

The steps to reproduce this: https://github.com/paulroberttaylor/lightning-out-recordeditform
  • March 11, 2018
  • Like
  • 0
Hi,

This should be pretty basic,
I have a vf page to display the value of the name field of a record in a custom object called 'Certification_Accredited_Centres__c'
I also have a controller that the vf page uses.

The URL passes a paramater 'centreId' which is the id of the record I am trying to get the name value of.

At the moment all I am getting on the vf page is "Assesments taken at      " <-- the string is blank

VF Page (not complete)
<apex:page controller="AddingAssessmentsController>
<h3>
<apex:outputText value="Assesments taken at {!asscen}"/>
</h3>
</apex:page>
Controller (not complete)
public class AddingAssessmentsController {

    public Id centreId;
    
    public String asscen{get;set;}
    
    public AddingAssessmentsController(){
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        String asscen = [SELECT name from Certification_Accredited_Centres__c WHERE id =: centreId].name;
    }
}

Please can someone tell me why the {!asscen} is blank in the vf page?

Thanks
Joe 
 
I am taking quantity of product in this field and storing number of quantity.its showing up down arrow..but on down arrow its going below 0 i.e -1,-2... so i dnt want values below 0.how do i restrict it????
public with sharing class expensesLineItem{
    public final Expense_Line_Item__c el;
    
    public expensesLineItem(ApexPages.StandardController stdController){
        this.el = (Expense_Line_Item__c)stdController.getRecord();
    }
    public PageReference Dismiss(){
        el.Display_Alert__c=false;
        update el;
        PageReference page = ApexPages.currentPage();
        page.setRedirect(true);
        return page;
    }
}


Test class:

@isTest
public class expensesLineItem_Test{
  @testSetup
  static void setupTestData()
  {
    Expense__c exp = new Expense__c();
    exp.Period_From__c = system.today();
    exp.Period_To__c =system.today();
    insert exp;
    System.assertNotEquals(null, exp.Id); 
    
    Expense_Line_Item__c expLine = new Expense_Line_Item__c();
    expLine.Name = exp.Id;
    expLine.Expense_Head__c='Food' ;
    expLine.Cost_Head__c= 'Campaign' ;
    expLine.Amount__c= 10000;
    System.assertNotEquals(null, expLine.Id);
    insert expLine;
 }
  
  @isTest 
  static void testCall()
  {
    Expense_Line_Item__c expLine  =  [SELECT Id,Name,Amount__c,Bill_Available__c,Cost_Head__c,Expense_Head__c,Expense__c from Expense_Line_Item__c][0];
   // System.assertEquals(true,expense_line_item_Obj.size()>0);
   // List<Expense__c> expense_Obj  =  [SELECT Id from Expense__c];
    //System.assertEquals(true,expense_Obj.size()>0);
    ApexPages.StandardController stdCon = new ApexPages.StandardController(expLine);
    expensesLineItem obj01 = new  expensesLineItem(stdCon);
    
    //expensesLineItem obj01 = new expensesLineItem(new ApexPages.StandardController(expense_line_item_Obj[0]));
    obj01.Dismiss();
  }
}
I'm trying to create a validation rule that requires a custom opportunity field to be populated (look up field) before being able to add a specific discount product to the opportunity. Is this possible? 

AND(
  ISBLANK(Ambassador_Referral__c),
  TEXT(Product2.ProductCode, 'REFDISCOUNT')
)

Error: Field Product2 does not exist. Check spelling.

i want to test a contoller class using Apex Message passed by the controller on the Vf page 

But i am not able to get any result as pageMessages comes null 

Any ideas how i can do it ?
 

static testMethod void test_Member(){
        
        //start the test process
        Test.startTest();
        
        Test.setCurrentPage(Page.BankManagement_Login);
        
        TransactionController obj = new TransactionController();
        
        ApexPages.Message[] pageMessages = ApexPages.getMessages();
        //List<Apexpages.Message> pageMessages = ApexPages.getMessages();  
        
        Boolean check=false;

        obj.username='aneesh@gmail.com';
        obj.password='12';
        obj.login();
        System.debug('hello1');
        
        for(ApexPages.Message msg:pageMessages){
          
            if (msg.getDetail().contains('Username Or Password is not valid')) {
                
                check = true;
                
            }else{
                
                check = false;
            }
        }
        
        system.assert(check);

        //Stop the test process
        Test.stopTest();
    }
Greetings all,
I have a visualforce page with an apex:inputfield for ownerid for the record to create a timesheet.  I would like to default the record owner name on the page to the current user (the current user will usually be creating a timesheet for themselves), but give them the ability to change the value in the owner field if they choose.  Currently the field is coming up blank, rather than with the current user.  Please advise.  My code is below.

I'm still pretty new to apex so any help is greatly appreciated. 

My VF page:
<apex:page standardController="Timesheet__c" extensions="PayPeriodExtension">
   
    <apex:form >
            
    <apex:pageBlock title="Select Pay Period">
      <apex:pageMessages /> <!-- this is where the error messages will appear -->

        <apex:pageBlockSection >
                
       	<apex:selectList size="1" required="true" value="{!PayPeriodID}">
          <apex:selectOptions value="{!ActivePayperiods}"></apex:selectOptions>
      	</apex:selectList>
        <apex:inputfield value="{!Timesheet__c.ownerid}"/>	<br/>

        </apex:pageBlockSection>
            <apex:pageBlockButtons >
            <apex:commandButton action="{! save }" value="Save" />        
        	<apex:commandButton action="{! cancel }" value="Cancel" />        
        </apex:pageBlockButtons>      
    </apex:pageBlock>
 </apex:form>
           
</apex:page>
My Controller Extension:
 
public class PayPeriodExtension {
    public ApexPages.StandardController stdCntrlr {get; set;}
    Public List  <Pay_Period__c> PPTemp = new List <Pay_Period__c>(); 
    Public String PayPeriodID {get; set;}
   
    // the contact record you are adding values to
  public Timesheet__c timesheet {
    get {
      if (timesheet == null)
        timesheet = new Timesheet__c ();
        timesheet.OwnerId = UserInfo.getUserId();
        return timesheet;
    }
    set;
  }
	public  PayPeriodExtension(ApexPages.StandardController controller) {
        stdCntrlr = controller;    
  }

   
    public List<SelectOption> ActivePayperiods
    {
        get
        {
            PPTemp = [Select Id, Name, Days_Since_Start_Date__c From Pay_Period__c 
                      Where (Days_Since_Start_Date__c <14 AND days_Since_Start_Date__c >-21) 
                      Order BY Days_Since_Start_Date__c desc ];
            ActivePayPeriods = new List<SelectOption>();
            
            for(Pay_Period__c temp : PPTemp)
            {
                ActivePayPeriods.add(new SelectOption(temp.id, temp.Name));
            }
            return ActivePayPeriods;
        }
        set;
    }
    
    public PageReference save() {
		
    try {
        timesheet.Pay_Period__c = PayPeriodID;
        upsert timesheet; // inserts the new record into the database
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new timesheet.'));
      return null;
    }

    // if successfully inserted new survey, then displays the thank you page.
    return (new ApexPages.StandardController(timesheet)).view();
  }

}



 
Hello,

I want to insert a value in my case field on before insert trigger . I have a static variable in controller whose value Iam initializing in a method in controller and when I access that variable in trigger It is showing "NULL".
and if I initialize the value while declaring then trigger prints the value.
refer the code below:

//this is the class.
public with sharing class Demo{
  public static String test;

public void testMethod(){

   test  = 'hello';


}

//this is the trigger.

trigger TestTrigger on Case (before insert) {
   
    System.debug(Demo.test);  //prints null

}
I´m trying to put a google maps on my standard object "Account" , i´m using the billing adress for the location, the map works fine for a few seconds than it appears this message:
User-added image

The code i´m using for this is:

<apex:page standardController="Account">
<head>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var myOptions={ zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP,mapTypeControl: false };
var map;
var marker;
var geocoder = new google.maps.Geocoder();
var address ="{!Account.BillingStreet},{!Account.BillingPostalCode}{!Account.BillingCity}, {!Account.BillingState},{!Account.BillingCountry}";
var infowindow = new google.maps.InfoWindow({
content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingState}<br>{!Account.BillingCountry}"
});
 
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(marker, 'click', function() {
infowindow.open(map,marker);
});
google.maps.event.addListener(infowindow, 'closeclick', function() {
map.setCenter(marker.getPosition());
});
}
} else {
$('#map').css({'height' : '15px'});
$('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
resizeIframe();
}
});
 
function resizeIframe() {
var me = window.name;
if (me) {
var iframes = parent.document.getElementsByName(me);
if (iframes&&iframes.length == 1) {
height = document.body.offsetHeight;
iframes[0].style.height = height + "px";
}
}
}
});
</script>
<style>
#map {
font-family: Arial;
font-size:12px;
line-height:normal !important;
height:250px;
background:transparent;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</apex:page>
Suppose i opened visualforce page , That insert the data into the DataBase. Is it possible in VisualForce?
Hi experts,
I need your help to build a formula as I am stuck here and don't know how to achieve the result that I want.

This is my formula :
if(ISNULL(Benefit_End_Date__c),12,round((Benefit_End_Date__c - Expected_Impact_Date__c),2)/30)
This formula returns 0 when the difference between the 2 dates are less than 30 days, so when there is less than a month.
In that case I would like to return 1. How cvan I do that?
It blocks me to implement a method as each time the result is 0 I get an error from Apex ...
Many thanks in advance for the time you will spend on my issue :)
Ludivine
This formula does not work for entire 24 hour clock in Pacific Time Zone.

CASE(MID ( TEXT (CreatedDate), 12, 2),"01",1," 02",2,"03",3,"04",4,"05",5,"06",6,"07",7,"08",8,"09",09,"10",10,"11",11,"12",12,"13",13,"14",14,"15",15,"16",16,"17",17,"18",18,"19",19,"20",20,"21",21,"22",22,"23",23,"00",00,Null)-(7)
Hi,

Case is always taking up from email address (generated from email-to-case ) even after I am selecting email action from feed action bar. Is that possible it takes logged in user email address instead of taking from email address of the case originaly created from email-to-case.

User-added image

Thanks in advance.
Gulshan Raj

 
Suddenly my developer profile is showing everything in Japanese. Any idea where you change language preference ?




Thanks in Advance.User-added image
queryStr='age__c=29'

Database.query('SELECT Id,Name,Age__c,Email__c,Course__c FROM Student__c WHERE '+queryStr+' LIMIT:20');
Hello Developers, I have apex class which consists of 2 queries and I want to merge it inside wrapper class.
here's my class
public class NonBillableReport {

    @AuraEnabled
    public static List<Event> getNonBillable(){
    List<Event> nonBill = [Select Subject, Id, Facilities__c, Services__c, Appointment_Status__c, OwnerId, WhoId,
             ActivityDateTime, ActivityDate, WhatId, Facilities__r.Address_1__c,Facilities__r.City__c, Facilities__r.Name,Facilities__r.Country__c, Sup_Provider__c,Sup_Provider__r.Name, Owner.FirstName, Owner.MiddleName, Owner.LastName,
EndDateTime, Facilities__r.State__c,
Sup_Provider__r.Provider_Role__c FROM Event WHERE IsRecurrence = false AND Appointment_Status__c = 'Non-Billable' LIMIT 100];
 return nonBill;

 List<Session> SessionRecords = [Select Case_Number__c,Case_Number__r.Client_Insurance__c,      Case_Number__r.Total_Amounts__c,Case_Number__r.Client_Insurance__r.Insurance_Type__c,Case_Number__r.Client_Insurance__r.Insured_ID__c,       Client_Name__c,Case_Number__r.Patient_Customer__r.Client_ID__c,Case_Number__r.Patient_Customer__r.DOB__c,Insurance_Name__c,     Case_Number__r.InsuranceType__c,Case_Number__r.Claim_ID__c,Case_Number__r.Insurance__r.Payer_Id__c,Case_Number__r.Insurance__r.Name,From_DOS__c,Case_Number__r.Location_Name__c,Case_Number__r.Facility_Type__c,Case_Number__r.Provider_Name__c,Case_Number__r.Provider__c,   Case_Number__r.Authorization_Number__c, Authorization_Number__c,Case_Number__r.CaseNumber , Procedure_Code__c,Modifier1__r.Name,Modifier2__r.Name,Modifier3__r.Name,Modifier4__r.Name ,Unit_Count__c, Case_Number__r.Billed_Amount__c,       Practice_Fee__c,Case_Number__r.Status,Case_Number__r.First_Bill_Date__c,Case_Number__r.Last_Bill_Date__c, ICD_Code__c,     	NDC_Code__c,NDC_Unit_Price__c,Unit_of_Measure__c,Case_Number__r.Unit__c,Case_Number__r.FacilitiesV3__c, 
Audit_Status__c,lastModifiedBy.Name, lastModifiedDate,PracticeFee__c FROM Case_Line_Item__c limit 10];
     }
}
Please help me or suggest if something is incorrect
 
apex for below scenario :

We have received list of duplicates and from that list we want to remove the duplicate on basis of name,email and phone number ? 



 
On account and contact there are field called acc-stage and con-stage respectively. (Checkbox)  If any acc has more than 2 contact and if all the 3 contacts have con-stage=true then only account acc- stage will reflect to true. If any contact’s con stag
How can a user see only his records and not other users' under the same object?  Note- My Owd settings for this Object Vanishes the  moment I click edit sharing settings. However i can see this Object on my sharing setttings page  Please help.

Visible at first
User-added imageNot visible on edit

User-added image
 
We have various SMS Templates as a CustomMetaData and need to add mergeField on these Metadata records. This MergeField is the fieldData on the custom lead object to which the SMS should be sent. Is this possible to add MergeFields on a MetaData Text field.
Hi everyone,

Essentially, I have a custom object called Repair and I'm trying to have it so a user can create a new Repair record with Status either "Not Started", "In Progress", or "Completed" and save it, but the catch is that Status is a picklist value and when a user selects completed from the Picklist and saves, the field should either become Read-Only after saving or cannot be changed after saving.

I currently have: 
AND (
ISPICKVAL(Status__c, "Completed"),
OR (
ISNEW(),
ISCHANGED ( Status__c )
))

as the Validation Rule to prevent it from being changed after saving, and it lets me save as "Not Started" and "In Progress" but not when it is set to "Completed".

I'm lost and I've been going at it for awhile - any help is appreciated. I've looked at other posts that have come close to getting to what I need but I haven't been able to get around the issue of not letting me save AS "Completed". It's technically doing the opposite of what I want it to do.
Hello,
Will someone help me with how do I get the row field values when a user updates a field?
I want to take the value from an updates field and multiply it by a value from another field(same row) and take the calculated value and put it into another field(same row).
I just need the syntax for getting the field values of the row.
I need to get this resolved so any help is greatly appreciated.

  • February 05, 2022
  • Like
  • 0
Hi All,

How to hide Jquery (Input) button in visualforce page and need to display particular profile.

Thanks
KMK
  • January 30, 2022
  • Like
  • 0
Hi All,

I'm trying to alert the User when a particualr value is selected within a picklist. 

In Object Manager I have the Standard Object, Case
Case Standard Object

And in the Case Standard Object I have the Case Reason with the field label and field name Case Reason and Reason respectively with the type Data Type picklist.

Within the picklist I have the Case Reason Picklist Values such as Accounts, ALL - Bank Holiday Routing etc.

On the Case Page Layout I have added a Visualforce Page and what I'm trying to do is to alert / popup a warning if the User selects a particular value - example Apex below
<apex:page standardController="Case">
    <apex:outputText id="myScript">
        <script>
            if(!Case.Reason == "ALL - Bank Holiday Routing") {
                window.alert("Alert");
                }
        </script>
    </apex:outputText>
    <apex:form >
        <apex:inputField value="{!Case.Reason}">
            <apex:actionSupport event="onselect" reRender="myScript"/>
        </apex:inputField>
    </apex:form>    
</apex:page>
However, currently nothing is displayed to the User so how can I display an alert when the User selects a value?

Any help greatly appreciated.
 
I want to create a class object knowing only its name. This object belongs to Batch, but I don't know which one. So i have to run it by name only. i get error when i pass sObject to executeBatch.
 
@AuraEnabled
    public static void run(String batchName){
        sObject newObject = (sObject)Type.forName(batchName).newInstance();
        Database.executeBatch(newObject);
    }
How to bypass it.
Thanks in advance.

I am trying to update the value of my object elements whenever one of the object is deleted. However, I always get the Uncaught ReferenceError: i is not defined error on my console. 

Here is my code 

deleteTask(event) {

this.todoTasks = this.todoTasks.filter(task => task.id !== event.target.name);
this.updateId();
console.log(this.todoTasks);
}
updateId(){
for(i=1; i<=this.todoTasks.length; i++){
this.todoTasks[i-1].id = i;
}
}

Hi Guys,

I am making a integration callout through connectedcallback function during that time i need to show spinner until data gets loaded this part i am able to do but in case on negative senario when i get no response i need to stop showing spinner and show error with error icon can you please help how to achive this functionality.



 
  • January 29, 2022
  • Like
  • 0
Hi,
How can I create a  visualforce page that replicates the list view of my custom object records, and the functionality of being able to select a record and then use the action button to add a New Competitor to this record and to populate the record that I have selected. Please see below.

User-added image

User-added imageI have create numerous visualforce pages in an attempt to replicate this functionality (where the Division is pulled through to the form) but nothing seems to be working. The Division is the master and the Competitor is the child in the master-detail relationship of the field "Division".

Thanks
Hi Gurus,

Please provide me a test class for below look up class
 
/**
* Class used to serialize a single Lookup search result item
* The Lookup controller returns a List<LookupSearchResult> when sending search result back to Lightning
*/
public class LookupSearchResult {

    private Id id;
    private String sObjectType;
    private String icon;
    private String title;
    private String subtitle;

    public LookupSearchResult(Id id, String sObjectType, String icon, String title, String subtitle) {
        this.id = id;
        this.sObjectType = sObjectType;
        this.icon = icon;
        this.title = title;
        this.subtitle = subtitle;
    }

    @AuraEnabled
    public Id getId() {
        return id;
    }

    @AuraEnabled
    public String getSObjectType() {
        return sObjectType;
    }

    @AuraEnabled
    public String getIcon() {
        return icon;
    }

    @AuraEnabled
    public String getTitle() {
        return title;
    }

    @AuraEnabled
    public String getSubtitle() {
        return subtitle;
    }
}

Regards,
Fiona​​​​​​​
1. write a soql query to fetch users whole role is Manager and profile is Executive;
 2.write a soql query to fetch all opportunities which are owned by above users;