• Vivian Charlie 1208
  • SMARTIE
  • 894 Points
  • Member since 2015
  • Senior System Executive
  • Eternus Solutions Pvt. Ltd.

  • Chatter
    Feed
  • 27
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 152
    Replies
Hi Everyone,

If I have a rollup field on account from rolling up opportunties $ will the currency be converted to what is set on my locale in my user personal settings or are there other implications I shoud know about.
I've created a button with this java script:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
sforce.apex.execute("buttonHandler","copyOLItoPP",{id:"{!Opportunity.Id}"}); 
location.reload();

but I keep getting this error whenever I try to click it:
{faultcode:'soapenv:Client; faultstring:'No such parameter id defined for operation. please check the WSDL for the service.'}
I am trying to copy over my opportunity products to a custom object (projects) by clicking a button. What does the code look like for that? I am very new to salesforce apex coding. 
I'm tasked with creating a custom controller that will add quote lines to Opportunity Product. How would I go about creating this controller to add the quotes? Sample code would be awesome!
If we convert a lead to an existing account we want that lead source to map over ONLY if account source = null. So if there is a new contact being added to the existing account, it wont override existing account source, however if there is no account source, we want the converted lead source to go to account source. 
Hi All,

In My org already recordtypes have been assigned with pagelayouts. 

Is there anyway that i can view which pagelayout is assigned to a particular recordtype.

Best Regards,
Mohammad Yaseen
can we update lookup field value by workflow rule?
Hi
We have the requirement that, rather than the below Contract Number, it should be the Contract Name, which is equivalent to Opp name above, Is that possible to do that ? or Can that contract auto number be changed to same as Opp number. As Contract is a standard field i couldnot found a way to do this. plz suggest. Thnx
 
User-added image
I have two orgs org1 and org2 . i want to create a vf page and controller in org1 which will display all the accounts present in org2 , let me know how it is possible?

Thanks and Regards,
Shiva RV
Hello Developes!

I have a trigger which counts number of unique email address contacts on Account.
Trigger Code:
Trigger UniqueEmailCons on Contact(After Insert, After Update, After Delete, After Undelete){
    
    List<ID> accountIds = New List<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUndelete){
        For(Contact con : Trigger.New){
            accountIds.add(con.AccountID);
        }
    }
    If(Trigger.IsDelete){
        For(Contact con : Trigger.old){
            accountIds.add(con.AccountID);
        }
    }
    
    Set<String> UniqueEmails = New Set<String>();
    List<Account> AccountListToUpdate = New List<Account>();
    
    For(Account act : [Select ID, Unique_Email_Contacts__c, (Select Id, Email FROM Contacts) FROM Account WHERE Id = :accountIds])
    {
        
        act.Unique_Email_Contacts__c = 0;
        
        For(Contact c : act.contacts)
        {
            If(C.Email != null)
            {
                UniqueEmails.add(C.Email);
            }
        }
        act.Unique_Email_Contacts__c = UniqueEmails.size();
        AccountListToUpdate.add(act);
        
    }
    try{
        update AccountListToUpdate;
    }
    Catch(Exception e){
        System.debug('Exception thrown is::: ' + e.getMessage());
    }
}
Trigger works fine for individual getting inserted, updated, deleted record etc.. but when I update all the contacts togather then all the accounts in org (let's say 18 ) of them gets updated as follow:

Account - 1 gets updated with values of Unique_Email_Contacts__c as 1
Account - 2 gets updated with values of Unique_Email_Contacts__c as 2
Account - 3 gets updated with values of Unique_Email_Contacts__c as 3 etc...


Thank you for the help!

 
Hi,

I want change the format of the currency for the BRL Currency.
So for example, I want change this format "1,000.00" to this format "1.000,00"
Note: The comma to BRL is the decimal separator.

Someone knows how change that?

Best Regards
Rafael
 
Have a fromula below that depending on how many checked it will sum up values into formula field with number return type. I would like to take this value in this formula field and create another that will convert to hrs.
 
IF (checkbox1__c, 15, 0) +  IF (checkbox2__c, 30, 0) + IF (checkbox3__c, 90, 0)

User-added image

Hi Everyone,

i have a list of records which fields i am using to create, one parent record and one child record.i have one list for both parent and child.

i am inserting those list outside the loop. Now i have to set relationship between those. i cant do this inside loop because its not inserted yet.

Not able to figure out how do i do this.

for(rolinesDetails rold : rols){ 
                      Repair_Order_Line__c rol = new     Repair_Order_Line__c();
                      rol.Quantity_to_Repair__c = rold.Quantity_Accepted;
                      rol.Created_From_ROL__c = true;
                      rol.Original_Inventory_Line__c =  ?? // how do i put inv line id here 
                      rolls.add(rol);
                      
                      Inventory_Line__c il2 = new Inventory_Line__c();
                      il2.Acquisition_Cost__c = rold.roline.Estimated_Repair_Cost__c;
                      il2.Serial_Number__c = rold.Serial_Number;
                      invlist.add(il2);
                    
        }
insert invlist;

insert rolls;
its seems simple but cant figure out the solution. And i also need rolinesDetails fields value for creating both records.

 RepairOrderLine is child and  InventoryLine is parent. Thanks in advance.

Thnaks,

Manohar

  

Hey, 

I'm trying to update a case with some details of the related email message. I need the case to be updated before Assignment rules are run. I would also like to limit the trigger to only fire when this is the first email associated to the case. I've been able to get it this far, but it's not working and I have no idea where I've gone wrong. Any help is greatly appreciated. 

Once this is working I'll move much of the work into a helper class and refactor the trigger into the existing case trigger. 
 
trigger EmailToCaseTrigger on Case(after insert) {
    system.debug('Here in Trigger');
    List<case> cases=new List<Case>();
    for(Case c:Trigger.new){
        List<EmailMessage> em=[select ToAddress,FromAddress,CcAddress,FromName from EmailMessage 
                               where ParentId=:c.Id and Incoming=true and Parent.Number_of_Messages_Received__c=0];
        	if(em!=null && em.size()>0){
            	c.Email_To_Address__c=em[0].ToAddress;
            	c.From_Address__c=em[0].FromAddress;
            	c.Email_CC_Address__c=em[0].CcAddress;
            	c.Email_From_Name__c=em[0].FromName;
            	cases.add(c);
        	}
    	}
    if(cases.size()>0)
    update cases;         
}

 
Hi there everyone,

I've looked through previous entries and couldn't find an entry that matched exactly what I was trying to do, so forgive me for yet another post.

I'm finding that my Visualforce page is not loading the rows correctly on the initial load. I've figured out that it is because there are no entries that match the 'null' parameter that is probably being used in my where clause. How do I pass a paremeter to my load routine on the initial load of the visual force page? I find that if I do an 'Insert' the desired table rows show up.  The code for my VF page and Controller are below:

VISUALFORCE PAGE

<apex:page standardController="Request__c" extensions="TrController" >
    <!--Because we will be defining 'Input' fields, we must wrap our code in a 'Form' block. -->
    <apex:form id="Time_Entry_Form">
        <apex:pageBlock title="CDCR - Salesforce Time Reporting for Requests" id="Time_Entry_List">
            <apex:pageBlockButtons id="Button_area">
                <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
                <apex:commandButton >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" type="submit">New</a>               
                </apex:commandButton>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
            <div class="displayPeek">
                <label>Result of Peek:</label>
                <apex:outputText value="{!Request__c.Id}"/>
            </div>
            <apex:pageBlockTable value="{!TimeEntries}" var="entry" id="Entry_Table_List">
                <apex:column width="45" headerValue="Action">
                    <a href="javascript:if (window.confirm('Are you sure?')) DeleteEntry('{!entry.Id}');" style="font-weight:bold">Del</a>               
                </apex:column>   
                <apex:column headerValue="Related Object">
                    <apex:inputField style="width:100%" value="{!entry.Related_Object__c}"/>
                </apex:column>  
                <apex:column width="70" headerValue="Activity">
                    <apex:inputField value="{!entry.Activity__c}"/>
                </apex:column>   
                <apex:column width="30" headerValue="Date Worked">
                    <apex:inputField value="{!entry.Date_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Hours">
                    <apex:inputField value="{!entry.Hours_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Worked">
                    <apex:inputField value="{!entry.Minutes_Worked__c}"/>
                </apex:column>   
                <apex:column headerValue="Work Description">
                    <apex:inputField style="width:100%" value="{!entry.Work_Description__c}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:actionFunction action="{!del}" name="DeleteEntry" reRender="Time_Entry_List">
            <apex:param name="EntryID" value="" assignTo="{!SelectedEntryID}"/>
        </apex:actionFunction>
        <apex:actionFunction action="{!add}" name="CurrRequest" reRender="Time_Entry_Form">
            <apex:param name="EntryID" value="" assignTo="{!ReqID}"/>
        </apex:actionFunction>

    </apex:form>
</apex:page>




CONTROLLER

public with sharing class TrController
{
    public List<Time_Entry__c> TimeEntries {get;set;}
    public string reqRslt {get;set;}
    public string showMessage {get;set;}
    //Used to get a hold of the entry record that is selected for deletion.
    public string SelectedEntryID {get;set;}
    public string ReqID {get;set;}
    public TrController(ApexPages.StandardController controller)
    {
        LoadData();
     }
    private void LoadData()
    {
        //Load the related time entry records from the database.
        TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c from Time_Entry__c WHERE Related_Object__c=:ReqId order by ID DESC];

    }
    public void save()
    {
        //Update the Salesforce database with the data entred.
        update TimeEntries;
    }
    public void add()
    {  
        //The following line will obetain the request id (ReqId) that is passed from the VisualForce page
        string RequestID = ReqId;
        //Build the default values to the new time entry record.
        Time_Entry__c entry = new Time_Entry__c(Activity__c='Research', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='00', Related_Object__c=RequestID);
        //Insert the new default time entry row into the Salesforce database.
        Insert entry;
        //Call the method to reload the Visualforce list.
        LoadData();
    }
    public void del()
    {   
        //if we are missing the reference, then do nothing except return.
        if (SelectedEntryId == null)
        {
            return;
        }
        
        //If the record is within the collection, then delete it.
        Time_Entry__c tobeDeleted = null;
        for(Time_Entry__c a : TimeEntries)
        if (a.Id == SelectedEntryId)
            {
                tobeDeleted = a;
                break;
            }
        //If account record found then delete it.
        if (tobeDeleted != null)
            {
                Delete toBeDeleted;
            }
        //Refresh the list
        LoadData();

    }

}  
Hello, I am new to triggers ...can anybody help me with this 

I have a lookup relationship between two custom objects A and B(the child)
when two checkbox fields in object A are unchecked, i want two other checkbox in obj B to be unchecked...

I know this can be done via process builder but would like to try this with  a trigger so I can start to understand more about Apex
  • April 14, 2017
  • Like
  • 0

Hello,

I have object like below

Account
  CustField1__c [Lookup to object CustObj1__c]

CustObj1__c
  Name [Text] Standard field
  CustomField2__c [Text]
My Usecase:

I have below Algorith to implement
 
If( CustomField2__c  == 'EEF')
  Then On Account CustField1__c = "Name of EEF"
Basically, i want to populate the name of the EEF, if it it present on Account.

I want to do it using combination of processbuilder and Flow,

thanks for suggestion !






 

  • April 14, 2017
  • Like
  • 0

Hello Developers!

I am trying to write a trigger on opportunity where it would throw an error when user exceeds 10,000 daily limit of opportunity amount. One sales rep can create number of opportunities up to the amount where Amount can not exceed 10,000 per day.

Here is my logic: When there is a new record inserted in system, I am getting that record's userId, and createdDate in variables. Then I have a SOQL which fetches the all opportunities in database which is created by that user and on the today's  date (I am not too sure my SOQL in the code below). Once the records are fetched, I have a loop which sumes up the amount from the fetched opportunities in SOQL and if that sum is greater then 10,000, I am throwing an error.
 

Trigger TenThousandDollarsLimit on Opportunity(Before Insert){
    // We need to write a trigger so one user can not create more then
    // $10,000 of opportunity per day.
    
    User OppOwner;
    ID OppOwnerID;
    Double AmountSum;
    Date TodaysDate;
    
    For(Opportunity opp: Trigger.New){
        
        OppOwner = opp.Owner;
        OppOwnerID = opp.OwnerId;
        TodaysDate = opp.createdDate.date();
        
        
        List<Opportunity> opps;
        opps = [Select Id, Amount FROM Opportunity WHERE OwnerId = :OppOwnerId AND CreatedDate = :TodaysDate];
        
        
        For(Integer I = 0; I < opps.size(); I++)
        {
            AmountSum = opps[I].Amount;
        }
        
        If (AmountSum > 10000){
            opp.addError('You have exceed your daily limit of $10,000');
        }
        else{
            // do nothing
        }
    }
    
}
Here is an Error Message while saving the first record:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger TenThousandDollarsLimit caused an unexpected exception, contact your administrator: TenThousandDollarsLimit: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TenThousandDollarsLimit: line 14, column 1


Thank you for the help guys!
Hello,

object: Account
  custfield__1 (Lookup to Obj1)

Obj1
  Name (Standard field: mandatory)

Usecase:
when account is created, the Name is autofilled or updated with value "XYZ" and make sure with a SOQL that the record is well present.

How could i implement it with Trigger ?

thanks you for suggestion.
 
  • April 13, 2017
  • Like
  • 0
Hello,

I have below object
Account
 CustomPicklist__1 (values: abc, def, ghi)
 Custom1__c (formula: values can be AB or BC or IL or US )

I am writing a process builder with this entry criteria
NOT($User.ByPass_WF__c) &&
NOT(ISNULL([Account].Custom1__c)) &&
CONTAINS("IL:US", [Account].Custom1__c )
&&
OR($Profile.Name == 'XYZ',$Profile.Name == 'ZZ1')
Usecase:
When the entry criteria is passed then the CustomPicklist__1  is set to abc ( CustomPicklist__1 =abc)

I am not able to specify the profile name in process builder.

Is there any way to implement the usecase.
I want to do it with process buider if not then Trigger

thanks for suggestion
 
  • April 13, 2017
  • Like
  • 0

Hi,

I have a requirement to edit an objects date field from my lightning component. With the relationship between the objects I have to create a wrapper to display the records and necessary date fields.

When I use aura:iteration with the wrapper ui:inputdate does not work properly. The date the user selects from the calendar does not get updated on the UI, however the values is updated in the back end.

When I use aura:iteration with a list of any concrete object ui:inputdate works properly. The date the user selects from the calendar gets updated on the UI, and the values is also updated in the back end.

Has anyone faced a similar issue and know of any work around for the same?

Thanks
Vivian

Hi,

I have a requirement to edit an objects date field from my lightning component. With the relationship between the objects I have to create a wrapper to display the records and necessary date fields.

When I use aura:iteration with the wrapper ui:inputdate does not work properly. The date the user selects from the calendar does not get updated on the UI, however the values is updated in the back end.

When I use aura:iteration with a list of any concrete object ui:inputdate works properly. The date the user selects from the calendar gets updated on the UI, and the values is also updated in the back end.

Has anyone faced a similar issue and know of any work around for the same?

Thanks
Vivian

I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
@isTest
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}

 
Hi All,

In my org I have three object obj1, obj2, obj3 and obj2 is junction object between obj1 and obj3. My requirement is i want a rollup summary field on obj1 which will calculate the minimim value of related obj3 field. 

Please help me how shalll i proceed in this case. Thanks

BEst Regards,
Mohammad Yaseen
Hi Everyone,

If I have a rollup field on account from rolling up opportunties $ will the currency be converted to what is set on my locale in my user personal settings or are there other implications I shoud know about.
I've created a button with this java script:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
sforce.apex.execute("buttonHandler","copyOLItoPP",{id:"{!Opportunity.Id}"}); 
location.reload();

but I keep getting this error whenever I try to click it:
{faultcode:'soapenv:Client; faultstring:'No such parameter id defined for operation. please check the WSDL for the service.'}
I am trying to copy over my opportunity products to a custom object (projects) by clicking a button. What does the code look like for that? I am very new to salesforce apex coding. 
If we convert a lead to an existing account we want that lead source to map over ONLY if account source = null. So if there is a new contact being added to the existing account, it wont override existing account source, however if there is no account source, we want the converted lead source to go to account source. 
Hi,
please help me out this

I need to display message on standard detail page when ever child records are inserting.

this is possible by InLineVisualForcePage

but how to give condition child records are inserted then only display message
can we update lookup field value by workflow rule?
I have two orgs org1 and org2 . i want to create a vf page and controller in org1 which will display all the accounts present in org2 , let me know how it is possible?

Thanks and Regards,
Shiva RV
How to display QuoteLineItem fields in an Visualforce Email Template when we are having relatedto = "Opportunity"?
public class AgregateFunctionOnTestObject {
    public static void Afterupdate(Map<id,Test123__c> newmap,Map<id,Test123__c>oldmap){
           list<id> ids= new list<id>();
        for(id key: oldmap.keyset()){
            Test123__c n1=newmap.get(key);
            Test123__c o1=oldmap.get(key);
             ids.add(key);
        }
    }
            list<Test__c> tc= new list<Test__c>();
    list<Test__c> t=[select Percentage__c,(select id from Test123s__r)from Test__c where id=:ids];
        for(Test__c t1:t){
            for(Test123__c r:Test123s__r){
            t1.Percentage__c= t1.Test123s__r.size();
            tc.add(t1);
        }        }  
}