• kritin
  • NEWBIE
  • 434 Points
  • Member since 2010

  • Chatter
    Feed
  • 17
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 129
    Replies

Apex trigger ContractCompliance caused an unexpected exception, contact your administrator: ContractCompliance: execution of BeforeUpdate caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contract.Status: Trigger.ContractCompliance: line 6, column 1

Error: Invalid Data. 
Review all error messages below to correct your data.

 

trigger ContractCompliance on Opportunity (before update) {
	
	for (Opportunity opp:Trigger.new){
		List<Contract> c = new List<Contract>([SELECT id from Contract where AccountId = :opp.accountid]);
		for(Contract cTypeObj :  c) {
			if (cTypeObj.Status == 'Activated Signed') {
				if (cTypeObj.Contract_ID_Prefix__c == 'MSA') {
					opp.ContractStructure__c = 'Yes';
					opp.MSA_or_Standalone_Effective_Date__c = cTypeObj.StartDate;
					
				}
			}
		}		
		
		List<Account> a = new List<Account>([SELECT id from Account where Id = :opp.accountid]);
		for(Account aTypeObj :  a) {
			opp.Legal_Account_Name__c = aTypeObj.Hoovers_Company_Name__c;
			opp.Customer_Contract_Street_Address_1__c = aTypeObj.Hoover_s_HQ_Address_1__c;
			opp.Customer_Contract_Street_Address_2__c = aTypeObj.Hoover_s_HQ_Address_2__c;
			opp.Customer_Notices_City__c = aTypeObj.Hoover_s_HQ_City__c;
			opp.Customer_Notices_Zip__c = aTypeObj.Hoover_s_HQ_Postal_Code__c;
		}
	}
}

 

The purpose of this trigger is to pull values of fields to the sObject Opportunity from the related Contract(s)and Account(s)

 

Hi,

 

I have written below trigger to calculate due date based on addition of no of days to start date(excluding Saturday and Sunday)

 

trigger calculateDueDate on Job__c (before insert,before update) {
    for (Job__c j : Trigger.New)   

{        if(j.Start_Date__c != null && j.No_of_Days__c != null)        {            DateTime st = j.Start_Date__c;            double d=j.No_of_Days__c;            Integer i=d.intValue();            DateTime et = st.addDays(i);                 while(st<et)            {                Integer count=0;                if(st.format('E')=='Sat' || st.format('E')=='Sun')                {                    count=count+1;                }                st=st.addDays(1);            }       }   } }

 

In the above code, how can i add count to variable et?

 

Regards,

Devendra S

I have an account, for which a contract was negotiated for a one-year period.

During this period, I expect to receive recurring orders, at approximately two months intervals.

 

Can you suggest what relationship should I create between the account/contract and opportunities,

so that I can show proper values in the sales pipeline?

 

1. Should I create individual opportunities for each expected P.O?

    (advantage: shows correctly in pipeline. Disadvantage: n:1 relationship with contract)

2. Should I create a single opportunity? (benefit: 1:1 relationship with contract.

    Disadvantage: how do I show it correctly in the pipeline?)

3. Another method?

I have a validation rule that requires the close date to be the first of the month.  So far i have tested the formula to work on every month but December.  I cant figure out where the logic is becoming broken for that month.  Any help?

 

DAY(CloseDate) <>
IF(Month(CloseDate)=12, 31,
DAY(DATE(YEAR(CloseDate),MONTH(CloseDate),1)))

 

Thanks!

Hi,

       I have one requirement to add Product standard functionality in custom object.so if anyone knows please help me.If any suggestion you have let me know.

 

Minkesh Patel.

I created a new object called End User Opportunities.  In it, I created most of the same attributes as in Opportunities.  How do I create the Stage - Probability relationship so that it automatically fills in the appropriate Probability when the Stage is selected?

I am writing a trigger to bulk update campaign records with the lead/contact owner name in a text field. I am trying to bulkify this trigger, but I am not updating more than one record at a time. How can i write the trigger to bulk update? Below is my trigger:

 

 

trigger CampaignOwner on CampaignMember (after insert, after update) {

    Set<Id> UserIds = new Set<Id>();
    for (CampaignMember ca: Trigger.new){
    System.debug('**** 0 userids id : '+ca.ownerid__c);
    
            UserIds.add(ca.ownerId__c);
     System.debug('**** 1 ca id : '+ca.id);
     
     }
    
    Map<Id, User> entries = new Map<Id, User>();
    List<user> us = [select Id, LastName, FirstName, Phone, Fax, Email from User where id in :UserIds];
    
    string txt = '';
    for(CampaignMember camp: [select id, Ownerid__c from CampaignMember]) {
        System.debug('**** 100 *********************us[0].Us.FirstName: '+us[0].FirstName);
    if(camp.Ownerid__c<> null){
       camp.Owner_Name__c = us[0].FirstName + ' ' + us[0].LastName;
        }
    update camp;
    }
}

 

Thank you

 

 

 

Hi,

  I want to create lead from email .I tried one appexchange but its not creating lead.Can anyone tell me a solution for this

 

Thanks

  • January 18, 2011
  • Like
  • 0

Hey Guys,

 

In the below trigger I am updating records on Contact Record from values on the Account. How can I bulkify this? It hits the Script limitations otherwise.

 

 

trigger trac_PrimaryContact on Account (after insert, after update) {
	
	List<String> updPContacts = new List<String>();
	
	for (Account a :Trigger.new) {	
		

		if(a.Contact__c != null) {
						
			updPContacts.Add(a.Affnet_Contact__c);
		}
	}
	
	
	//Update Contacts
	if(updPContacts.Size() > 0) {
				
		Contact[] myCons = [SELECT Id, FirstName, LastName, Email, Title FROM Contact WHERE ID IN :updPContacts];
										
		for(Contact myC :myCons) {
			
			for (Account a :Trigger.new) {	
								
				if(myC.Id == a.Contact__c) {
					
					myC.FirstName = a.First_Name__c;
					myC.LastName = a.Last_Name__c;
					myC.Email__c = a.Email__c;
					myC.Title = a.Title__c;
				}
			}
		}
		
		update myCons;			
	}	
}

 

 

 

trigger farmingTasksGenerator on Opportunity (after update) {
	Task t;
	List <Task> tasksToInsert = new List <Task> ();
	List <Opportunity> oppList = [SELECT Id, Status_Code__c, FA__c, Name, Senior_HMA__c
								 FROM Opportunity WHERE Id IN :Trigger.NewMap.keySet()];
	
	
	for (Opportunity opp: oppList) {
		
		if (Trigger.newMap.get(opp.Id).Status_Code__c != Trigger.oldMap.get(opp.Id).Status_Code__c  ) {
			
			if (opp.Status_Code__c == 'A15' ||
				opp.Status_Code__c == 'C10' ||
				opp.Status_Code__c == 'C20' ||
				opp.Status_Code__c == 'E10'	) {
				
				t = new Task (Subject = 'Farming task - ' + opp.Status_Code__c + 
										' - loan ' + opp.Name, WhoId = opp.FA__c,
								ActivityDate = System.Today()+1, WhatId = opp.Id, Status = 'Not Started', 
								RecordTypeId = '012300000008qRE', Farming_Task__c = true, Type = 'OUTBOUND CALL',
								OwnerId = opp.Senior_HMA__c, isReminderSet = true, ReminderDateTime = System.Now(),
								Farming_Task_Description__c = 'Farming task - ' + opp.Status_Code__c + 
										' - loan ' + opp.Name);
				tasksToInsert.add (t);
			}
		}
	}
	
	insert tasksToInsert;
	tasksToInsert.clear();
	oppList.clear();

}

 We have a trigger that is supposed to create tasks for specific loans that are moved to a specific status. Update is run every morning and updates 3000 records from CSV file and that is when trigger is fired. For some reason, it creates the same task for some but not all records... Any ideas?

 

Thank you. 

 

Hi developers,

                        Help..... I got one problem in my developer account, in opp. stage picklist  closed won & closed lost values are not  in the list. But, i can find at field values creation part of the object. How can i get to visualize that values into pagelayout

hi,

 

In apex class (in method) i wrote a statement like,

 

a=mod(n,10);

 

but it returned error.

 

I would like to perform the mod() operation.

How can i do it...

 

please help me.

 

  • December 20, 2010
  • Like
  • 0

Hi All,

 

Is it possible to hide "new" option for related list? I have created a custom link to create new detail records. Now I want to hide "new" option of the related list. Could any one please let me know how to do this? Your help is greatly appreciated.

  • December 20, 2010
  • Like
  • 0

Hi,

 

 

I hav an object in that I have emailId field. I want to take all the emailId's in that object to a List<String>.

 

how to do this?

 

please help me.........

 

 

Regards,

 

shra1

Hi to all

 

I need some help from you guys. I created a visualforce page with custom controller to display specific data. Then I use that page as a tab in customer portal. The problem is that the data are not displyed when I logged in as a portal user. In the matter of user permission I already enable the access of customer portal user for both custom controller and visualforce page. In fact, the tab was already there and the pageBlock title was displayed (message displayed in pageBlock title was a method in the custom controller something like title="{!method_in_custom_controller_that_returns_a_string_message}").

 

Somehow the pageBlockTable does not display the data it should display.

 

Someone please enlighthen me on this matter and bring to the right track, what possibly am I missing here.

I need to change a customer object's owner based on 2 factors:

 

1)  5 later than the time recorded in a object field name "AppliedAt", and

2)  if a related custom object (Master - Detail relationship) record count is 0 (e.g., there are no Detail records).

 

What's the best way to do this?  Is the Apprivo app necessary, or is their native force.com capabilities?

 

Thx.

Hi All.

 

I am have trouble with governor limits when I run test cases for my application.

 

System.Exception: Too many SOQL queries: 21Trigger.dsContactTrigger: line 388, column 32

 

My application has 5 batch processes which I need to test and triggers on update insert and delete for account contact and lead.

 

Thanks

Hector.

We need to pass these china Address in web-service callout. We are just simply setting the web-service method API field like  mthdParamListM1.chn_st1=string.valueOf(Cont.Street_Name_China__c);

And getting web-service callout Error. Please help us.

 

Geeting Webservice Callout failure Parse Error.

 

 This is the chinese character that we want to pass.

上海古北路620号院内WTO办公楼
 


Hi All,

 

How can we handle China special character Address in Web-service Callout?

 

 

上海古北路620号院内WTO办公楼

 

We need to pass these china Address in web-service callout. We are just simply setting the web-service method API field like  mthdParamListM1.chn_st1=string.valueOf(Cont.Street_Name_China__c);

And getting web-service callout Error. Please help us.

 

 

Error:

Web service callout failed: WebService returned a SOAP Fault: com.boomi.process.ProcessException: First document failure: Error invoking soap operation; Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source: ; Caused by: Unable to create envelope from given source: ; Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 3-byte UTF-8 sequence.; Caused by: Invalid byte 2 of 3-byte UTF-8 sequence. faultcode=S:Server faultactor=

How to write before delete trigger on Opportunity and change the record type of Opportunity and prevent it from its actual deletion without adding error in record.

http://boards.developerforce.com/t5/Apex-Code-Development/change-the-Record-type-of-Opportunity-on-delete/td-p/236131

  • January 24, 2011
  • Like
  • 0

I needed one help with respect to writing of one trigger on Opportunity for before delete trigger. my objective is to We want to change the record type of opportunity to Deleted Opportunity once user cliks Delete button. I know we can override button with S-Control/javascript. but i want to build this login Opportunity trigger. means change the Record type of Opportunity on delete and prevent this from deletion of record without adding any error.

  • January 18, 2011
  • Like
  • 0
Please help!! How can we set Task type='To Do' in workflow rule create task.
  • December 23, 2010
  • Like
  • 0
Please help!! How can we set Task Type='To Do' in workflow rule create task.
  • December 23, 2010
  • Like
  • 0

how can we read/extract IP Range from profile in Apex or through external API.Please help

  • December 06, 2010
  • Like
  • 0

hi

 

this is my trigger when i am trying to insert two fulfilments of  same item and warehouse then its saying dupolicate id and is unable to update my list so how can i resolve my issue plz help

 

trigger Wow_Fulfillment_FIFO_SNUM_LOTNUM on Fulfillement__c (after insert,after update) {

public list<Inventory_Transaction__c> ITList1{get;set;}
ITList1 = new List<Inventory_Transaction__c>();


for(Fulfillement__c f:trigger.new)
{
Inventory_Transaction__c[] IT = [select id,Item__c,Qty_In__c,Dev_Bucket_Qty_Remaining__c,Qty_Out__c,warehouse__c
from Inventory_Transaction__c where Item__c =:FF.Item__c AND
Warehouse__c =:FF.warehouse__c AND Dev_Bucket_Qty_Remaining__c != 0
Order By Date__c asc];

 


IT[0].qty_out__c =IT[0].qty_out__c+FF.qty_out__c;
ITList1.add(IT[0]);

}
update ITList1;
}

i have updated it in the list to avoid dml staement error but its giving me duplicate id to update so plz help how to remove the duplicate id that comes into a list

Hi all,

 

I am trying to recover some Contacts form a Visualforce page through an Apex class.

 

Since I click on the Contacts tab, I get to a view list where some contact are selected by their checkbox. A new button has been added to the View List to take these contacts to another page. When I get this page, the contacts are shown in a pageBlockTable. How do I get to recover these contacts from the extension Apex page?

 

Thanks in advance

Apex trigger ContractCompliance caused an unexpected exception, contact your administrator: ContractCompliance: execution of BeforeUpdate caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contract.Status: Trigger.ContractCompliance: line 6, column 1

Error: Invalid Data. 
Review all error messages below to correct your data.

 

trigger ContractCompliance on Opportunity (before update) {
	
	for (Opportunity opp:Trigger.new){
		List<Contract> c = new List<Contract>([SELECT id from Contract where AccountId = :opp.accountid]);
		for(Contract cTypeObj :  c) {
			if (cTypeObj.Status == 'Activated Signed') {
				if (cTypeObj.Contract_ID_Prefix__c == 'MSA') {
					opp.ContractStructure__c = 'Yes';
					opp.MSA_or_Standalone_Effective_Date__c = cTypeObj.StartDate;
					
				}
			}
		}		
		
		List<Account> a = new List<Account>([SELECT id from Account where Id = :opp.accountid]);
		for(Account aTypeObj :  a) {
			opp.Legal_Account_Name__c = aTypeObj.Hoovers_Company_Name__c;
			opp.Customer_Contract_Street_Address_1__c = aTypeObj.Hoover_s_HQ_Address_1__c;
			opp.Customer_Contract_Street_Address_2__c = aTypeObj.Hoover_s_HQ_Address_2__c;
			opp.Customer_Notices_City__c = aTypeObj.Hoover_s_HQ_City__c;
			opp.Customer_Notices_Zip__c = aTypeObj.Hoover_s_HQ_Postal_Code__c;
		}
	}
}

 

The purpose of this trigger is to pull values of fields to the sObject Opportunity from the related Contract(s)and Account(s)

Hi,


I have 2 objects:

 

Milestones, and Actions, Actions is the child object (look up relationship)

 

In the Actions object I have a field called "total hours"

 

I would like to get the sum of the "total hours" in a Milestone object field called “Sum of Hours”

 

As there is no master detail relationship so I cannot create a roll up summary field.

 

I guess it can be done with a trigger. Does anyone have a sample trigger for this?

 

Thank you!

  • October 05, 2011
  • Like
  • 0

Hi All,

     i want to create tab in vf page.Suppose i want to place custom account tab.when we click on that tab .vf page with with new button appears.Any can u please help me that.

 

Thanks in advance.

 

Hi,

 

I have a doubt in Quote Template.

 

I have created a new custom field in Setup->Customize->Quote->Quote Line Items->Fields. The field name is Product Description.

 

When i go to Quote Template I can see this newly added field. What i need to do is i need to display the actual Product Description here. That is the product description from the Product Object. What i suppose to do. The Product Code is a Standard Field in the Quote Line Item, but there is no Product Description available, i need to add this to the Quote Template. Please help.

 

Thanks and Regards

Hari G S

Hi All,

 

I am new for the implementing Web Services API calls in the Salesforce.

Please can any one mention best practices to implement the Apex callouts with using Salesforce web services API  to get the data from External Servers and from different objects with in Salesforce and Vice versa. and also mention best sources for documentation.

 

Thanks in advance.

  • September 19, 2011
  • Like
  • 0

Hi,

 

I am developing <apex:pages>.Now i need to integrate the <apex:page> with the BackEnd coding.For that REST Api have to be invoked.

 Can anyone please suggest me  on how to Invoke REST Api from <apex:page>.

Hi,

 

I am able to get PopUp using apex coding as explained in the below link.

 

http://www.salesforcegeneral.com/salesforce-modal-dialog-box/

 

But page include is not working.i.e the page which is included in the PopUp using <apex:pageInclude>. Can any one please guide how to include page in the PopUp

 

 

 

 

 

 

 

How to make first letter of each word of sentence should be capital in visualforce ?

I have used apex:outputtext to show my text then how can i show it ?

I know LOWER is used for lowercase & UPPER is used for uppercase.

 

Hi,

 

I have created custom objects, JobTask, JobTaskRole

 

JobTask store the various tasks and JobTaskRole stores roles associated with the JobTask.

 

one JobTask can contain multiple Roles, therefore i have kept master-detail relationship between JobTask and JobTaskRole


JobTaskRole consist of following fields : JobTask__c(Relationship with master) and Role(TextField)


Now i want to assign this Job Task to multiple users base,
1) Is it possible to store multiple users in the same object itself (into the JobTaskRole)? If yes, then how to do it?
2) Do i required to create one more object that will store users for one particulare role?

 

I am looking for an efficient way to do this functionality.
Regards,

Devendra S

 

Hi,

 

I have written below trigger to calculate due date based on addition of no of days to start date(excluding Saturday and Sunday)

 

trigger calculateDueDate on Job__c (before insert,before update) {
    for (Job__c j : Trigger.New)   

{        if(j.Start_Date__c != null && j.No_of_Days__c != null)        {            DateTime st = j.Start_Date__c;            double d=j.No_of_Days__c;            Integer i=d.intValue();            DateTime et = st.addDays(i);                 while(st<et)            {                Integer count=0;                if(st.format('E')=='Sat' || st.format('E')=='Sun')                {                    count=count+1;                }                st=st.addDays(1);            }       }   } }

 

In the above code, how can i add count to variable et?

 

Regards,

Devendra S

can any one help on this ..

HI,

I have stuck in one small issue

that is i wrote visualforce email template in it data is taken directly from database with out any sorting format . 

 

Now i want to sort it and display it , i want to sort date field.

 

  • September 08, 2011
  • Like
  • 0

Hello every1,

 

I am working on knowledge base  articles. i am using data categories assigning to my articles. i have a problem regarding serach of articles which are based on datacategories. i tried map, list, set, etc,etc.

but still the issue is same..

 

I also used knowledge:articlelist on vf but of no use.

 

So can any body please help me for this..

my exact prob is--

 

i have 10 categories in a category group.

i want to access only 9 in the search like

 

Categorygroup--> Tutorial

---> RCA

-->Bucket1

-->Admin

--->Bucket2

--->Test

-->Bucket3

Now i want to access only 2 not ol 3.. so can any body help me to solve this issue...

 

Thanks

Vishal

  • September 08, 2011
  • Like
  • 0

hi,

 

How to add of javascript into visualforcepage(opportunity)

 

thanks.

I recently uploaded a managed beta of my app to my test org for the first time, and I'm seeing some very strange behavior! My app contains a page which uses the Contact standard controller to display a list of contact names and email addresses. This works fine for me in the test org, and it works fine for another user I created - but the third and fourth users I created see no list of contacts!

 

I have verified that both have created several contacts, so the problem isn't simply that they have no contacts. Yet it seems like the contact list just isn't being populated by the Contact controller. I just don't get why this works for some users and not for others. Any ideas? I've pasted a copy of my Visualforce page below. (The controller extension doesn't do anything exciting, it just handles input and some redirects). 

 

If anyone has any idea what the problem could be, I would be very grateful to learn it!

 

<apex:page standardController="Contact" extensions="ListExtension" recordSetVar="contacts" tabStyle="Card__tab">
    <apex:form >
        <apex:pageBlock title="Contact List" mode="edit">
         <apex:image id="banner" value="{!$Resource.banner}"/><br/>
            <apex:pageMessages />
            <apex:outputPanel id="contactList"> 
            <apex:commandButton value="Configure" action="{!configure}"/>
            <apex:pageBlockTable value="{!contacts}" var="contact">
                <apex:column value="{!contact.Name}"/>
                <apex:column headerValue="Email" value="{!contact.email}">
                </apex:column>
                <apex:column headerValue="Select">
                    <apex:commandButton value="Select" action="{!chooseContact}" rerender="contactList">
                        <apex:param name="cemail" value="{!contact.email}" assignTo="{!contactEmail}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:pageBlockTable>  
            </apex:outputPanel>    
        </apex:pageBlock>
    </apex:form>
    </apex:page>

 

 

 

Hi all,

      I need to integrate salesforce with Quick books through APIs..can u give me the sample code and help me. its urgent.

 

Thanks in advance

anu 

  • August 08, 2011
  • Like
  • 0