• anvesh@force.com
  • NEWBIE
  • 64 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 11
    Likes Received
  • 2
    Likes Given
  • 182
    Questions
  • 71
    Replies
I am unable to get the value from below contact. how we can get the related field data ?

trigger NIGO_update on NIGOs__c(before insert,before update)

     for(NIGOs__c ng:Trigger.new){
     
    NIGOs__c nigo = Trigger.newMap.get(ng.Id);
            if(ng.Product_Type__c != 'Forecare'){
            if(ng.Contact_Name__c != Null){

                ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id; (Here i am getting Null Value)


                

            }
        }
        System.debug('Ext1'+ng.External_Wholesaler__c);
    }
         
}
I am unable to get the value from below contact. how we can get the related field data ?

trigger NIGO_update on NIGOs__c(before insert,before update)

     for(NIGOs__c ng:Trigger.new){
     
    NIGOs__c nigo = Trigger.newMap.get(ng.Id);
            if(ng.Product_Type__c != 'Forecare'){
            if(ng.Contact_Name__c != Null){

                ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id; (Here i am getting Null Value)


                

            }
        }
        System.debug('Ext1'+ng.External_Wholesaler__c);
    }
         
}
I have created a trigger.. contact is lookup. and i am assigning contact obj user value to current object.debug logs showing the value existed. but it is not assigned in record field.?



trigger NIGO_update on NIGOs__c(before insert,before update){

List<NIGOs__c> NgList = [select id,name,Contact_Name__c,Product_Type__c,Contact_Name__r.Annuity_Territory_Wholesaler__r.id,Contact_Name__r.Annuity_Territory_Wholesaler__c,Contact_Name__r.Forecare_Territory_Wholesaler__r.id from NIGOs__c  where id in:Trigger.new];


for(NIGOs__c ng:NgList){
if(ng.Product_Type__c != 'Forecare'){
if(ng.Contact_Name__c != Null){

ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id;

}
}
System.debug('Ext1'+ng.External_Wholesaler__c);
}

}
I have created a formulae field which displays phone no. But i am getting like  6678894949 some thing like this...

I want to have in a phone formatt. (812)-547-1458. Please help me
I am trying to insert Contact Role on Opportunity. But with my trigger 2  same records were inserted. why and how to make it not allowing duplicate record ?

trigger Opportunity_Primary on Opportunity (before insert,before update, After Update) {
 
   List<OpportunityContactRole> OppContactRole = new List<OpportunityContactRole>();
    OpportunityContactRole ocr = new OpportunityContactRole();
   set<OpportunityContactRole> sid = new set<OpportunityContactRole>();

    for (Opportunity O : Trigger.new) {
        if (O.Contact_Name__c!=Null){
          
            ocr.OpportunityId = O.Id;
            ocr.ContactId = O.Contact_Name__c;
            ocr.IsPrimary = True;

            sid.add(ocr);  
            OppContactRole.addall(sid);      }
            
    }

    if(OppContactRole.size()>0)
    insert OppContactRole;

    }
https://developer.salesforce.com/forums/#!/feedtype=RECENT&criteria=ALLQUESTIONSI am facing a difficult issue...as If and else statements were executed at a time.The difficult is  it was executed correctly in sand box and not 
in production it was executed if and else statements at a time......after if statement it enters in to else statement.


 for(Market_Metrics__c c: cIsBeforeAnnuity)
        {
              System.debug('tlistAnnuity'+tListAnnuity);         
        try
         {
            if(c.Exclude_from_Territory__c == false)
            {
               for(Territory__c t: tListAnnuity)
               {
                if(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
                 {
                  System.debug('AccountTest'+aIBDMap.get(c.SFDC_Account_Name__c).Name);                 
                  System.debug('ClsBefore'+cIsBeforeAnnuity);
                  System.debug('AccountChannel'+aIBDMap.get(c.SFDC_Account_Name__c).channel__c);  
                  System.debug('Protected Accounts'+t.Protected_Accounts__c);
                 
                 if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c && c.Zip_Code__c.substring(0,5) <= t.zip_end__c && t.type__c =='Annuity' && aIBDMap.get(c.SFDC_Account_Name__c).Name == t.Protected_Accounts__c)
                          {
                      System.debug('EntryTest1'+t.Protected_Accounts__c);                 

                      c.Annuity_Territory__c = t.Id;  
                                                                                          
                      System.debug('The current ID is Pro ' + t.Id);                  
                  }                             
                 else
                      if
(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
                 {                       
                    System.debug('ProtAcc'+t.Protected_Accounts__c);

                    if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c &&
                      c.Zip_Code__c.substring(0,5) <= t.zip_end__c && aIBDMap.get(c.SFDC_Account_Name__c).channel__c == t.channel__c &&t.type__c =='Annuity'&&t.Protected_Accounts__c == null)

                    {
                     System.debug('Entry Test2'+t.Protected_Accounts__c);

                          c.Annuity_Territory__c = t.Id;   
        
                      System.debug('The current ID is >>' + t.Id);
                    }                  
                 }                 
         catch (System.Exception e)
         {
            System.debug(e.getMessage());         
            //c.addError('[Error AC] There was an unexpected error while saving the record, please Contact support for assistance');               
         }
       }

      


 
I have created a visual force page. i am creating Opportunity record through the contact related list. So after 'New'  is asks record type selection then opens custom VF page. after save the Opportunity record doesnt appear in the contact related list. Please help me.

The contact related list  'New'  button is also custom button.
I want to remove focus from first field and want to set the focus on other field while the pages load. But below script doesnt work to set the cursor point on to  other field. can you please how can resolve in my custom visual force page.

<apex:page standardController="Opportunity"  extensions="OppStandardForcarePage">
<apex:sectionHeader title="Opportunity Edit"  subtitle="New Opportunity"/>

<!--<script type="text/javascript">
  window.onload = setFocus
  function setFocus() {
    document.getElementById("Ac").focus();
  }
</script>-->

<apex:form >

<script>
  function setFocusOnLoad()
  {
   document.getElementById("AcText").focus();    //see the id for account field below
  }
</script>



<apex:pageBlock title="Opportunity Edit" mode="edit">

<apex:actionRegion >
<apex:pageBlockSection title="Opportunity Information" columns="2" collapsible="2">
<apex:inputField value="{!Opp.AccountId}" taborderhint="1" id="AcText"/>
I created Visual force page and created contact using <apex:input field value{!Opportunity.contact}

Is the Text box of id will change in the VF page. when i go to the inspect eliment i saw a different Id's for Text box.

If this is the case i have 4 VF pages on same object(Oportunity) based on different record types. I have to pass the values(contact,account) on custom button. If diff id's is there how should i do this?
I want auto populate contact and account fields when ever we create Opportunity record from contacts related list. But  below was not giving as expected results...please anyone make correct.


PageReference pr = new PageReference('/apex/OppVfPage?CF00N40000002fEB2={!Contact.Name}&CF00N40000002fEB2_lkid={!Contact.Id}&conid={!Contact.Id}');

after page opens the contact or account fields were not populated and the URL displays like...

https://c.cs15.visual.force.com/apex/OppVfPage?CF00N40000002fEB2=%7B%21Contact.Name%7D%3FCF00N40000002fEB2_lkid%3D%7B%21Contact.Id%7D%3Fconid%3D%7B%21Contact.Id%7D

 
I have created 2 VF pages and i want to display those VF page according to the record type selection. But it was showing 2 VF pages one by one at a  time. Please any one suggest or modify the below.


<apex:page controller="OppRenderPageClass">
   <apex:outputPanel rendered="{!IF(Opportunity.RecordTypeId == '012400000009mCCAAY',true,false)}">
        test<apex:outputField value="{!Opportunity.RecordTypeId}"/>
        <apex:include pageName="OppVfPage" />
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!IF(Opportunity.RecordTypeId !='01240000000UWKDAA4',true,false)}">
        <apex:include pageName="LostReason" />
    </apex:outputPanel>
    
</apex:page>
need for only users assigned to 2 certain roles can create ‘private’ Contacts (Contact records with no associated Account). 
I have List method in a controller class...and i am going to call this  Method  in Test class. But i am getting  Method does not exist or  Incorrect signature error ? can any one resolve this.

This is the method in Controller class :

 public List<Building_Owner__c> contactList {
        get {
            if (contactList == null) {
                contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
            }
            return contactList;
        }
        set;
    }


Test Class :

LCBSBuildingOwnersController bc = new LCBSBuildingOwnersController();   // creating controller class
        bc.newBuildingOwner();
        bc.Order();
        bc.buidingCancel();
        bc.buidingSave();
        bc.getContractorCompanyLoc();   // this is the page reference method calling correct
         bc.contactlist();   // this is the List method (How to call this method)

 
I want to write Test class for  below controller class code. Pleease help me  how to write in Test Class.

tList;
        }
        set;
    }
public List<Building_Owner__c> contactList {
        get {
            if (contactList == null) {
                contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
            }
            return contac

 
I have writtened a Trigger. Used check recursive to stop after the trigger fire.  But when i writeened in Test class the code coverage is not passed. when i remove check recursive it is passed. How to overcome this. please suggest me.

Trigger code :

trigger StageTrigr on Opportunity (before insert,before update) {
if(checkRecursive.runOnce()){
    Boolean bool = true;
    List<Opportunity> OppUp = new List<Opportunity>();
    for(Opportunity c : Trigger.new) {
        if(Trigger.Isupdate){
        Opportunity oldOpp = Trigger.oldMap.get(c.ID);  
        if(oldOpp.StageName!=NULL && oldOpp.StageName == '5-Paperwork/Ticketing incoming'){
            if (c.StageName == '1-Discovery') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            if (c.StageName == '2-Hypo / Illustration delivery') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            if (c.StageName == '3-Rep follow up - VM') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            if (c.StageName == '4-Client Meetings') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            if (c.StageName == '5-Paperwork/Ticketing incoming') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            if (c.StageName == '6 - Close Lost') {            
                    c.StageName = '6 - Close Lost';            
            }
            if (c.StageName == '7 - Close Won') {            
                    c.StageName = '7 - Close Won';            
            }
        }
        if(oldOpp.StageName != '5-Paperwork/Ticketing incoming'){
            if (c.StageName == '5-Paperwork/Ticketing incoming') {            
                    c.StageName = '5-Paperwork/Ticketing incoming';            
            }
            
        }
        if(oldOpp.StageName!=NULL && oldOpp.StageName == '4-Client Meetings'){
            if (c.StageName == '1-Discovery') {            
                    c.StageName = '4-Client Meetings';            
            }
            if (c.StageName == '2-Hypo / Illustration delivery') {            
                    c.StageName = '4-Client Meetings';            
            }
            if (c.StageName == '3-Rep follow up - VM') {            
                    c.StageName = '4-Client Meetings';            
            }
            if (c.StageName == '4-Client Meetings') {            
                    c.StageName = '4-Client Meetings';            
            }            
            if (c.StageName == '6 - Close Lost') {            
                    c.StageName = '6 - Close Lost';            
            }
            if (c.StageName == '7 - Close Won') {            
                    c.StageName = '7 - Close Won';            
            }
        }
        if(oldOpp.StageName != '4-Client Meetings'){
            if (c.StageName == '4-Client Meetings') {            
                    c.StageName = '4-Client Meetings';            
            }
            
        }
        }
        
        
              
        }
        }
    
}

Check Recusrsive Class :

Global Class checkRecursive{
    global static boolean run = true;
    public static boolean runOnce(){
    if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
}


Test Class :

@isTest(SeeAllData = false)

private class Test_UpdateStageTrigger
{
public static void resetRunOnceFlag() {
checkRecursive.run = TRUE;
}
static testMethod void UnitTestForException()
{
//checkRecursive.run  = false;

Account ac = new Account ();
ac.name = 'Test Account';
ac.Status__c = 'Active';
ac.Channel__c = 'Bank';
insert ac;

User u = [ select Id from User where id =: UserInfo.getUserId() ];

Territory__c Tr = new Territory__c();
Tr.wholesaler__c = u.id;
Tr.name = 'Test Territory';
Tr.Division__c = 'East';
Tr.Type__c = 'ForeCare';
insert Tr;

Contact c = new Contact();
c.Lastname = 'test';
c.Accountid = ac.id;
c.MailingState = 'CA';
c.MailingCity = 'SAN DIEGO';
c.MailingPostalCode = '92121';
c.Forecare_Territory__c = Tr.id;

insert c;

List<Opportunity> Olist = [select id,name,stagename,closedate from Opportunity where Contact_Name__r.id =:c.id];

Opportunity O = new Opportunity();

O.Name = 'Test Opp';
O.AccountId=ac.Id;
O.StageName='1-Discovery';
O.CloseDate=Date.Today();

insert O;
// System.assert(checkRecursive.runOnce(), 'Recursion check failed. Please review checkRecursive recursion logic');


O.StageName = '5-Paperwork/Ticketing incoming';

Update O;

Opportunity O1 = new Opportunity();

O1.Name = 'Test Opp1';
O1.AccountId=ac.Id;
O1.StageName='2-Hypo / Illustration delivery';
O1.CloseDate=Date.Today()+1;

insert O1;
 //checkRecursive.run  = false;

O1.StageName = '5-Paperwork/Ticketing incoming';

Update O1;


Opportunity O2 = new Opportunity();

O2.Name = 'Test Opp2';
O2.AccountId=ac.Id;
O2.StageName='3-Rep follow up - VM';
O2.CloseDate=Date.Today()+10;



insert O2;
 //checkRecursive.run  = false;
          

O2.StageName = '5-Paperwork/Ticketing incoming';

Update O2;




}
}
I had written Test class for below sample trigger code. But  it covered only 56% code coverage. I did all correct. can anyone make it 100% ?

Trigger Code :

trigger AcUpdate on Account (Before Insert,before update) {

for(Account A : Trigger.new){
If( A.SE2_Id__c == '20004')
A.name = 'RBC WEALTH MANAGEMENT';


If( A.SE2_Id__c == '20002' )
A.name = 'JJB HILLIARD LYONS';

If( A.SE2_Id__c == '20000' )
A.name = 'FTB ADVISORS INC';


If( A.SE2_Id__c == '20005' )
A.name = 'BB&T SECURITIES LLC';


If( A.SE2_Id__c == '20003' )
A.name = 'KEY INVESTMENT SERVICES';
}
}


Test Class :

@IsTest
public class AcUpdate_Test{
public static testMethod void main(){

Account ac = new Account ();
            ac.name = 'RBC WEALTH MANAGEMENT';
            ac.Status__c = 'Active';
            ac.SE2_Id__c = '25546';
            ac.Channel__c = 'Bank';
       
            insert ac;
            
            ac.SE2_Id__c = '25346';
            ac.name = 'RBC WEALTH MANAGEMENT1';
            update ac;
            
            Account ac1 = new Account ();
            ac1.name = 'JJB HILLIARD LYONS';
            ac1.Status__c = 'Active';
            ac.SE2_Id__c = '25586';
            ac1.Channel__c = 'Bank';
            insert ac1;
            
            ac.SE2_Id__c = '22546';
            ac1.name = 'RBC WEALTH MANAGEMENT12';
            
            update ac1;
            
            Account ac2 = new Account ();
            ac2.name = 'Test Account3';
            ac2.Status__c = 'Active';
            ac2.SE2_Id__c = '125456';
            ac2.Channel__c = 'Bank';
            insert ac2;
            
            ac2.SE2_Id__c = '12546';
            ac2.name = 'RBCSD WEALTH MANAGEMENT12';
            
            update ac1;
            
            Account ac3 = new Account ();
            ac3.name = 'Test Account4';
            ac3.Status__c = 'Active';
            ac2.SE2_Id__c = '21254';
            ac3.Channel__c = 'Bank';
            insert ac3;
            
            ac2.SE2_Id__c = '15256';
            ac3.name = 'RBC WEALTH MANAGEMENT31';
            update ac3;
            
            Account ac4 = new Account ();
            ac4.name = 'Test Account5';
            ac4.Status__c = 'Active';
            ac4.Channel__c = 'Bank';
            ac2.SE2_Id__c = '8546';
            insert ac4;
            
            ac2.SE2_Id__c = '5740';
            ac4.name = 'RBC WEALTH MANAGEMENT41';
            update ac4;


}
}

 
I have created a new opportunity button to populate opp values when ever opp page opens. And the button is under contact related list.

I created a trigger to overide the opp owner.

Button works correctly for admin..but when a user trying to create particuler recordtype opportunity he is getting insufficient previliougies error.

for other record type is able to create  opp record. I knew this is becvause of changing the owner name(Overriding) for opp. but how could it works ok for one record type and not working for another ?

he able to create record for 1 recordtype  logs -

04:34:51.413|CUMULATIVE_LIMIT_USAGE_END 04:34:50.740 (740278429)|CODE_UNIT_FINISHED|PrevStageTest on Opportunity trigger event BeforeUpdate for [006f000000D5aoL] 04:34:50.821 (821373378)|WF_ACTIONS_END| Field Update: 2; 04:34:50.821 (821396245)|CODE_UNIT_FINISHED|Workflow:Opportunity 04:34:51.331 (1331173392)|CODE_UNIT_FINISHED|TRIGGERS 04:34:51.331 (1331200916)|EXECUTION_FINISHED

Below is users canot able to create record for other record type.


04:31:09.265 (265616071)|VALIDATION_PASS 04:31:09.265 (265636279)|CODE_UNIT_FINISHED|Validation:Opportunity:new 04:31:10.603 (1603656178)|CODE_UNIT_FINISHED|TRIGGERS 04:31:10.603 (1603683968)|EXECUTION_FINISHED


if you observe for correct record workflow was executed. and for other validation rule executed. please need help very badly.
 
I have cloned a custom profile. and Role also cloned. I have added some users. But users are not  able to edit the 'Event'. In OWD Activity is  Controlled by parent. and the profile has 'Edit Event'  checked.

The parent profile users were able to edit. we cloned same profile why event is not editable ?
need for only users assigned to 2 certain roles can create ‘private’ Contacts (Contact records with no associated Account). 

I have recently created a new public calendar labeled 'Forecare Interviews'.  The business is requesting that an email alert be sent to the email address

anvesh@gmail.com 15 minutes before the start time of any meeting. i need  help to create a workflow rule  and added a time dependent action to the rule (it appears we can only do whole hours). 

 

i  am  working  in  enterprise  edition  but  in  that  "Email Alert "  action  is  not  visibled  y?

I have recently created a new public calendar labeled 'Forecare Interviews'.  The business is requesting that an email alert be sent to the email address

anvesh@mail.com 15 minutes before the start time of any meeting. i need  help to create a workflow rule  and added a time dependent action to the rule (it appears we can only do whole hours). 

 

i  am  working  in  enterprise  edition  but  in  that  "Email Alert "  action  is  not  visibled  y?

As   Admin  Created  a  Record  in  Activity  object.........and  OWD  settings  are  "Controlled By  Parent " for  Activity  obj.

but  the  problem is  user  is  unable  to  access  this  Record. this  user  assignrd to some Role. what could be the reason. records created by admin  should  visible  to  evry user by default. but  user  unable  to access.

 

the  error  is.

 

In Sufficient  Prevelegious

 

What  could be the reason?  can i  share the record?

In Contact  i  have  a  Field   "MTD Sales".  this  Field  is  Rollup SUM  to  another Object  "Policy" Field . and  this  Policy Field Name is  "Sales".

 

and  this  Policy  Field  "Sales" is  Rollup SUM  to  other object Transaction, the  Field  name  is  "Amount."

 

is this  clear? if any querries ask me about this question for better understand.

 

So  simple  in  Transaction  Field we have "Amount"  field, so  we enter  amount. 

in  policy  object  "Sales" Field  has Rollup  on  this  "Amount".

In  Contact  "MTD  Sales"  Calculated  from  "Sales" which is  Rollup  on  Policy obj .

 

                                         Roll UP  (SUM)                                          Roll UP  (SUM)

MTD  Sales (Contact) -------------------------------------->     Sales (Policy)   -------------------------------------->Amount (Transaction)

 

 

So  in  Policy  Object  "Sales"  field 

 

 

                                      (Field)                  (Opertaot)            (Value)

Field  Criteria  is          CurrentMonth              Equals                  Y

 

 

This  "Y"  value  is  coming  in  flat  files we  upload  data  through dataloader  and  "Currnt month"  field  is  Transactions Obj Field. 

 

so  now the  problem  is the  current  month  calculation  is  Wrong caluculating.  it  was  Calculating  Last  30 Calender  days  instead of  calculating Current  month.  please  give  me  sollution  can i  write  any  formulae  or  workflow  for  this ?  if  so  provide  sollution  also.

 

i  want  to  give  some  more information. i  have  a  filed   "Month  Calculation" on  Transaction obj.  This  is  Formulae  field. and  the  formulae   written in  this  is..

 

IF (
(Month(TODAY()) = (Month (Transaction_Date__c))), "Y", "N")

 

By using  this  Field can  we  write  any  workflow  to  Calculate  Current  month  Calculations? how  to  trigger  this.

when field met certain value  then that record  should need to  delete...is this  possible  through  trigger....

 

My requirement is  i have field  Activity_Type__c ='  ' (is  no value)..then this record should be deleted. so  i written this trigger but  not working.

 

trigger DeleteTask on Task (after insert) {

task t= new task();
if(t.Activity_Direction__c==''){
task t1=t.clone();
t.remove(t1);
}

}

 

Please anyone have sollution?

When i  deployed my trigger from sanbox to production , the deployement is failed , i  found that  at least 1% code coverage should need to have in order to deploy...but this trigger have 0% code coverage?  what should i do? hw to increses code coverage for this trigger?

 

 

 

trigger UpdateEventRating on Event (before insert, before update) {
for(Event E : Trigger.new){
if(E.Rating__c=='-Excellent Meeting (committed to business within 3 weeks)'){
E.Rating_Value__c=5;
}
else
if(E.Rating__c=='-Good Meeting (Resulted in client meeting agreed to/set or booked a seminar)'){
E.Rating_Value__c=4;
}
else
if(E.Rating__c=='-Productive Meeting (Client specific illustration requested or next meeting scheduled)'){
E.Rating_Value__c=3;
}
else
if(E.Rating__c=='-Average Meeting (Agreed to continued discussions, no client specific activity)'){
E.Rating_Value__c=2;
}
else
if(E.Rating__c=='-Poor Meeting (No potential for future business, no further activity needed)'){
E.Rating_Value__c=1;
}
}
}

Let me clear  first.....

 

Some    records(belongs to case object)  are  created.....and that  cases  assigned to  users....

 

after i  have requirement  to  create a field  with name 'owner'(cusom field)  having look up (in look up  displayes  users).....

 

 

now  the  requirement is  when  users  opened  the  records  the  owner  field should need to be  updated with the   current  user name......how  should i  write  field update  through workflow....

 

i  have this  field on  Record type  'Production Support '....so  condition  i had  taken  is

 

Rule Criteria -  "Created"

 

Case- Case  Record Type       equals     Production_Support (this is record typr name)

 

workflow action i had  taken  feild update  on   Owner (Custom field)....next    i  am getting  Owner  field  with look up here..what  should i  give  here   for  getting  current  user name (who  openes the record  his name).

 

through  workflow is this possible or any other solution for this.

i  created a   custom field  'Owner' in sandbox  and  it  appears when the record is opened....now  need to move to production.  and  the thing is  how  to  add a workflow rule so the field updates with the current user when the record is opened. 

 

 

Any Suggestions Pls,

 

i  have a feild  named  owner  of type textbox and have lookup relation....

 

now the thing is   when i  clicked  new  button (to create)  all fields are displayed including owner field but this feild default should displayed  as  current user name in the text box...how we can do this  any one pls?.

I  am  importing data  to  'POLOCY'  object.......i have a  feild  'Living Benifit Rider' of  type  "Multi  picklist".....now  when  i  import the  data The 'Living Benefit Rider'  field is populated with a string of text from the  file import.  I would like a validation rule so that only the values that exist in the field MultiPick list are displayed in the record.  but the problem  is  some records are rejected  even the value  exist in the picklist. when  i  remove this validation rule  then it was inserted. now the problem is   it  gives the error when the picklist value inserted. but requirement is it ll gives error other than picklist value

 

 

This  is  Validation  Rule  and  Error Message : Living Benefit Rider must be a pick list value.

 

OR
(
INCLUDES(Living_Benefit_Rider__c , 'Guaranteed Interest Rate') ,
INCLUDES(Living_Benefit_Rider__c , 'No GLWB') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Annual Single') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Annual Joint') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Daily Single') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Daily Joint') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Annual Single Legacy Lock') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Annual Joint Legacy Lock') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Daily Single Legacy Lock') ,
INCLUDES(Living_Benefit_Rider__c , 'GLWB Daily Joint Legacy Lock') ,
INCLUDES(Living_Benefit_Rider__c , 'TEST')

)

 

Error Message : Living Benefit Rider must be a pick list value.

 

 

I have created a trigger.. contact is lookup. and i am assigning contact obj user value to current object.debug logs showing the value existed. but it is not assigned in record field.?



trigger NIGO_update on NIGOs__c(before insert,before update){

List<NIGOs__c> NgList = [select id,name,Contact_Name__c,Product_Type__c,Contact_Name__r.Annuity_Territory_Wholesaler__r.id,Contact_Name__r.Annuity_Territory_Wholesaler__c,Contact_Name__r.Forecare_Territory_Wholesaler__r.id from NIGOs__c  where id in:Trigger.new];


for(NIGOs__c ng:NgList){
if(ng.Product_Type__c != 'Forecare'){
if(ng.Contact_Name__c != Null){

ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id;

}
}
System.debug('Ext1'+ng.External_Wholesaler__c);
}

}
I have List method in a controller class...and i am going to call this  Method  in Test class. But i am getting  Method does not exist or  Incorrect signature error ? can any one resolve this.

This is the method in Controller class :

 public List<Building_Owner__c> contactList {
        get {
            if (contactList == null) {
                contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
            }
            return contactList;
        }
        set;
    }


Test Class :

LCBSBuildingOwnersController bc = new LCBSBuildingOwnersController();   // creating controller class
        bc.newBuildingOwner();
        bc.Order();
        bc.buidingCancel();
        bc.buidingSave();
        bc.getContractorCompanyLoc();   // this is the page reference method calling correct
         bc.contactlist();   // this is the List method (How to call this method)

 
I want to write Test class for  below controller class code. Pleease help me  how to write in Test Class.

tList;
        }
        set;
    }
public List<Building_Owner__c> contactList {
        get {
            if (contactList == null) {
                contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
            }
            return contac

 
I have created a new opportunity button to populate opp values when ever opp page opens. And the button is under contact related list.

I created a trigger to overide the opp owner.

Button works correctly for admin..but when a user trying to create particuler recordtype opportunity he is getting insufficient previliougies error.

for other record type is able to create  opp record. I knew this is becvause of changing the owner name(Overriding) for opp. but how could it works ok for one record type and not working for another ?

he able to create record for 1 recordtype  logs -

04:34:51.413|CUMULATIVE_LIMIT_USAGE_END 04:34:50.740 (740278429)|CODE_UNIT_FINISHED|PrevStageTest on Opportunity trigger event BeforeUpdate for [006f000000D5aoL] 04:34:50.821 (821373378)|WF_ACTIONS_END| Field Update: 2; 04:34:50.821 (821396245)|CODE_UNIT_FINISHED|Workflow:Opportunity 04:34:51.331 (1331173392)|CODE_UNIT_FINISHED|TRIGGERS 04:34:51.331 (1331200916)|EXECUTION_FINISHED

Below is users canot able to create record for other record type.


04:31:09.265 (265616071)|VALIDATION_PASS 04:31:09.265 (265636279)|CODE_UNIT_FINISHED|Validation:Opportunity:new 04:31:10.603 (1603656178)|CODE_UNIT_FINISHED|TRIGGERS 04:31:10.603 (1603683968)|EXECUTION_FINISHED


if you observe for correct record workflow was executed. and for other validation rule executed. please need help very badly.
 
I want to add if condition for below Opportunity button.  where Opportunity recordType is  'Flexy' then i have to  populate Task picklist field values as 'Flex'...if Opportunity recordType is 'Matue' then I have to populate Task picklist field value as 'Matue'. But when i added below If condition is getting syntax error.


/00T/e?who_id={!Contact.Id}&RecordType={!Task.RecordTypeId}&tsk6={!Opportunity.Description}&tsk1={!User.Name}&tsk13 = 'Normal'&00N40000002dXt2 = {!Opportunity.Product_Interest__c}&tsk3= {!Opportunity.Name}&tsk3_lkid ={!Opportunity.Id}&tsk4={!TODAY()}&{!IF(Opportunity.RecordTypeId=='012400000009mCC' ,  ISPICKVAL(!Task.Product_Type__c, 'VA') , NULL)}&tsk5={!Opportunity.Name}&retURL=%2F/006/o
 am retreiving  opportunity records  under a contact (Contact Related list opportunities)  and displaying in a page table......i  am retreving all data  and every thing is good.  But i want add a filter condition where  sample Hype = true. then  all opportunity records under contact where sample hypo field is true should need to retrive.  But  after applying  condition i am getting  Referring a Null object exception for Olist.add(Op)  in below code.  I rendered the Olist in VF page pageblock table. I am not getting error in the code/VF.. after  rendered this to a button. After click buttoon it need to pull records and display here i am getting error.


public with sharing class OppRelatedData {

public Id sid{get;set;}
public string sname{get;set;}    


public list<Opportunity> OppRecords {get; set;}
public list<Opportunity> Olist = new list<Opportunity>();
 
contact cn = new contact();
string contactId = ApexPages.currentPage().getParameters().get('rec');
public OppRelatedData(ApexPages.StandardController controller) {

try{
if(ApexPages.currentPage().getParameters().get('rec')!=null){
 OppRecords = [select id,name,Amount,Sample_Hypo__c,Client_Meeting_Date__c,CloseDate,CreatedDate,Last_Activity_Date__c,LastModifiedDate,StageName,Product_Interest__c,Product_Riders__c from Opportunity WHERE Contact_Name__r.id =:ContactId  AND (not StageName LIKE '%close%') ORDER BY CloseDate ASC ];
System.debug('Opprecords'+OppRecords );
 for(Opportunity op:OppRecords){
 if(op.Sample_Hypo__c == true){
 
 Olist.add(op);
 System.debug('Olist'+Olist);
 
 }
 }
 update Olist;

}
else
System.Debug('There is no contact associated with Opportunity');
}

catch(DmlException e){
System.Debug(e.GetMessage());
}
}
}
HI please can anyone  resolve below code. Why i am getting System.Limit Exception. I am unable to find out the reason.

LA Detail ,LA Summery 2 objects...while i am inserting/Updating Bulk records getting this error. Its working while manually inserting 1 record.

trigger LAdetail on L_A_Detail__c (before insert,before update) {

set<string> Tset = new set<string>();
set<string> Cset = new set<string>();

set<string> Lset = new set<string>();

List<L_A_Detail__c> Dlist = new List<L_A_Detail__c>();

Map<string,string> LDetailMap1 = new Map<string,string>();
Map<string,string> LSumeryMap2 = new Map<string,string>();

for(L_A_Detail__c La : Trigger.new){
Tset.add(La.SE2_ID__c);
Cset.add(La.Appointment_State__c);
Lset.add(La.License_Number__c);
LDetailMap1.put(La.SE2_ID__c+La.Appointment_State__c,La.SE2_ID__c+La.Appointment_State__c);
}

List<L_A_Summary__c> LAlist = [select id,License_Number__c,SE2_ID__c,Appointment_State__c from L_A_Summary__c  where SE2_ID__c in:Tset And Appointment_State__c in:Cset And License_Number__c in:Lset];

for(L_A_Summary__c Al : LAlist){
LSumeryMap2.put(Al.SE2_ID__c+Al.Appointment_State__c,Al.SE2_ID__c+Al.Appointment_State__c);
}

for(L_A_Detail__c D : Trigger.new){
for(L_A_Summary__c S : LAlist){
string s1 = LDetailMap1.get(D.SE2_ID__c+D.Appointment_State__c);
string s2 = LSumeryMap2.get(S.SE2_ID__c+S.Appointment_State__c);

if(s1==s2){
if(D.Line_of_Business__c == 'Health'){
S.Health__c = True;
}

if(D.Line_of_Business__c == 'Life'){
S.Life__c = True;
}

if(D.Line_of_Business__c == 'Variable'){
S.Variable__c = True;
}

if(D.Line_of_Business__c == 'Annuity'){
S.Annuity__c = True;
}

if(D.Line_of_Business__c == 'Casualty'){
S.Casualty__c = True;
}

if(D.Line_of_Business__c == 'DI'){
S.DI__c = True;
}

if(D.Line_of_Business__c == 'Fixed'){
S.Fixed__c = True;
}

if(D.Line_of_Business__c == 'Long Term Care'){
S.Long_Term_Care__c = True;
}

if(D.Line_of_Business__c == 'Property'){
S.Property__c = True;
}

if(D.Line_of_Business__c == 'Variable Life'){
S.Variable_Life__c = True;
}

}
try{
update LAlist;
}
catch(DMlException e){
System.debug(e);
}
}


}
}
I have created an  'new Opp' button for opportunity. and placed in Contact related list as list button. i have 2 record types for opportunity. when i click Opportunity from contact related list it opens Opportunity page and after filling details it save successfully.  But for  Some profile users they are unable to save and getting insufficient previligious for one of Record Type. For other record type it works fine for user. As an administritator it works fine for me for both record types. where is the problem ?  here is my button code.

/setup/ui/recordtypeselect.jsp?ent=Opportunity&CF00N40000002fEB2={!Contact.Name}&CF00N40000002fEB2_lkid={!Contact.Id}&retURL={!Contact.Id}&save_new_url=%2F006%2Fe%3Flookupcmpgn%3D1%26accid={!Account.Id}&conid={!Contact.Id}
I have a User having profile. he has create read update permissions at his profile level. But  when i am trying to create Opportunity record from contact's related list gettig insufficient previligious error.
Is  contains/text operator works for  picklist/Multi pick list fields ?. I am unable to write condition for this. Please can any one help me how to write for picklist/Multi pick fields?

Policy is Detailed object and contact is Master , they are in master detail relationship. we can  create policy records from  contact  related list.

On policy  i have a field   "issue Date". and on contact i have checkbox field  "Current Year".

 suppose if i have created 2 policy records from contact related list, this means  contact  has 2 associated policy records. if  that 2 policy records "issue Date" is "equal or less than 60 Days" then the contact checkbox(Current year)  field should be True (Checked).

Need Trigger For this?

  • October 25, 2013
  • Like
  • 1

I have a field OpenedTaskDate__c on Task  this is date field.

i should need to display this date on contact field (TaskTestDate__c). so i have writtened a trigger like this

trigger updateTrig on Contact (before insert,after insert , before update) {
Task T =new Task();
for(contact c:Trigger.new)
c.TaskTestDate__c= t.OpenedTaskDate__c;


but it was not displaying the task field value on contact field.

In contacts i have a field TaskTestDate.  on this field i should need to display recently opened task date belongs to appropriate record type.

so correct my trigger.


trigger updateTrig on Contact (before insert,before update) {
Task T =new Task();
for(contact c:Trigger.new)
if(t.RecordtypeId=='01240000000UWKG')
c.TaskTestDate__c=t.t.system.now();
}

the T.system.date.now is not correct but how should i make this to populate a date of recently opened task date.

In Contact  i  have  a  Field   "MTD Sales".  this  Field  is  Rollup SUM  to  another Object  "Policy" Field . and  this  Policy Field Name is  "Sales".

 

and  this  Policy  Field  "Sales" is  Rollup SUM  to  other object Transaction, the  Field  name  is  "Amount."

 

is this  clear? if any querries ask me about this question for better understand.

 

So  simple  in  Transaction  Field we have "Amount"  field, so  we enter  amount. 

in  policy  object  "Sales" Field  has Rollup  on  this  "Amount".

In  Contact  "MTD  Sales"  Calculated  from  "Sales" which is  Rollup  on  Policy obj .

 

                                         Roll UP  (SUM)                                          Roll UP  (SUM)

MTD  Sales (Contact) -------------------------------------->     Sales (Policy)   -------------------------------------->Amount (Transaction)

 

 

So  in  Policy  Object  "Sales"  field 

 

 

                                      (Field)                  (Opertaot)            (Value)

Field  Criteria  is          CurrentMonth              Equals                  Y

 

 

This  "Y"  value  is  coming  in  flat  files we  upload  data  through dataloader  and  "Currnt month"  field  is  Transactions Obj Field. 

 

so  now the  problem  is the  current  month  calculation  is  Wrong caluculating.  it  was  Calculating  Last  30 Calender  days  instead of  calculating Current  month.  please  give  me  sollution  can i  write  any  formulae  or  workflow  for  this ?  if  so  provide  sollution  also.

 

i  want  to  give  some  more information. i  have  a  filed   "Month  Calculation" on  Transaction obj.  This  is  Formulae  field. and  the  formulae   written in  this  is..

 

IF (
(Month(TODAY()) = (Month (Transaction_Date__c))), "Y", "N")

 

By using  this  Field can  we  write  any  workflow  to  Calculate  Current  month  Calculations? how  to  trigger  this.

Policy is Detailed object and contact is Master , they are in master detail relationship. we can  create policy records from  contact  related list.

On policy  i have a field   "issue Date". and on contact i have checkbox field  "Current Year".

 suppose if i have created 2 policy records from contact related list, this means  contact  has 2 associated policy records. if  that 2 policy records "issue Date" is "equal or less than 60 Days" then the contact checkbox(Current year)  field should be True (Checked).

Need Trigger For this?

  • October 25, 2013
  • Like
  • 1

I have two custom objects as   master detail relationship.Inorder to retrieve related list from the master record using SOQL query and display it in visualforce page