• AdrianCC
  • SMARTIE
  • 1220 Points
  • Member since 2012

  • Chatter
    Feed
  • 42
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 301
    Replies
I have a trigger on opportunites that will add a field from a custom object (TSG__c)  if a match is found on .P21_Customer_ID.  The issue is that when multiple records are being updated through an upsert (Informatica Cloud) all of those opportunites are getting updated with the same field value.

Below is my trigger, please let me know where I went wrong.

Thanks again.


TRIGGER populate_TSG on Opportunity (before insert,before update) {

Set<string> ss = New Set<string>();
List<TSG__c> TheTSG=new LIST<TSG__c>();  
   
//Loop through all records in the Trigger.new collection
FOR(Opportunity O: Trigger.new)
{
    ss.Add(O.P21_Customer_ID__c );
}

TheTSG = [SELECT ID from TSG__c WHERE P21_CompanyCustomer_ID__c IN: ss];
   
    System.debug('@@@@--'+TheTSG.size());

    IF (TheTSG.size() >0)
    {
        For (Opportunity O: Trigger.new)
        {
            For(TSG__c tsg:TheTSG)
            {
               
           
            O.p21_account_number__c = tsg.ID;
            System.debug('@@@@--'+tsg.ID);
           
            }
        }
    }
}

Hi All,

 

I am a complete novice to the development side, especially Apex and am trying to create a trigger that will 'roll-up' or sum a field from a child record and I can't use standard roll ups due to limits. I have found a lot of code that can help with normal roll ups but the tricky part of what I am trying to do is that the child records of a specific 'type' can only be counted once and there is also another requirement that a field on the child record can't be empty. And that field is only populated, by other code, after the record is inserted. 

 

So basically it's a child object linked to Accounts. When a child is updated, the trigger will need to check if a child record with a specific type already exists for that account. The 'type' field on the child object  is a picklist field. If it does NOT already exist then the field on accoints called points will need to be increased by 10.  If it does already exist then nothing will happen and the record will just be updated as normal. Also, there will need to be an after delete so that when a child record is removed and it is the only one of that type, 10 points will need to be removed from the field on accounts. 

 

I am probably over complicating it but does anyone out there have a similar code I could take a look at that would give me a good starting point?

 

I am looking to create an exact clone of our production Salesforce instance into a new, completely separate enterprise instance of Salesforce. I would like everything to clone over such as custom objects, fields, triggers, workflows, apex classes, visualforce pages, etc. Has anyone been through a similar situation? I'm looking for all and any advice on the easiest way to complete this task.

 Thank you in advance!!

  • November 11, 2013
  • Like
  • 0

I need to create a view.. i call it approve view..

 

It has three tabs.

 

One fetch data from lead, // xyz fields.

second from a account converted from that lead, //xyz fields.

third from a opportunity from the above account.

 

I want to pass id of opportunity and view the above information for the opportunity...
is that possible in sales force if yes how??

 

 

 

I have some comfort with SQL, but not enough that I feel comfortable making changes to some of our internal call cycle logic without clarifying what the current query means.  My main question/confusion is around the "from FROM Account_Territory__c a" statement.  When I look at that object in my metadata, many of the fields used in the query below are not housed there (LCDFI_c, a.Customer__r.Revenue_Gain_or_Decline__c, and a few others), but they are all located within the overarching Accounts object.  If any of the metadata tables within the account object are referenced, can I "call on" any of the fields in the account object?  If not, how do I determine which metadata object to set the WHERE statement to?  If so, why would I not just reference the Account object to begin with?

 

One of my projects is around cleaning up these queries, and since I am new to this part of SF I wanted to make sure I am going in the right direction.  Thanks for any and all help!

 

 

SELECT Id, a.Customer__r.Id, a.Customer__r.Type, a.Customer__r.LCDFI__c, a.Customer__r.LCD_All__c, Primary_Team_Member__c 
FROM Account_Territory__c a
WHERE $existingAccountIdCriteria $customerTypeCriteria
$primaryCoverageCriteria 
a.Territory_Custom__c = $territoryId and 
a.Remove_From_Call_Cycle__c = false and a.Is_Marked_for_Delete__c = false and 
a.Customer__r.Sales_Ok_To_Call__c !='No' and ((a.Customer__r.$LCDField = null) OR
(a.Customer__r.$LCDField < LAST_N_DAYS:$DBC)) and 
a.Customer__r.Revenue_Gain_or_Decline__c < 0 
ORDER BY a.Customer__r.Revenue_Gain_or_Decline__c desc, a.Customer__r.$LCDField NULLS LAST 
LIMIT $capacity

I have a InputText object with an embedded ActionSupport that activates with the OnChange event to call a method from the Controller Extension. In reduced form here:

 

<apex:pageBlockSection showHeader="True" columns="2" title="Pricing" id="pricingBlock”>
   <apex:pageBlockSectionItem >
      <apex:outputLabel value="Discount" for="discProxy"/><apex:inputText value="{!discountText}" id="discProxy”>
         <apex:actionSupport event="onchange" 
                             action="{!afterDiscChange}" 
                             rerender="pricingBlock" />
      </apex:inputText>
   </apex:pageBlockSectionItem>
</apex:pageBlockSection>

 

It works perfectly except when someone changes the value in the text field and then immediately clicks on the Save button (or hits return which invokes the Save button). ie Does not click (or tab) elsewhere first. In this case, the code in afterDiscChange() is not executed and since it is meant to change a field value that we subsequently want saved it leads to an unwanted/unexpected result.

 

I tried replacing onchange with onblur but got the same (non)result.

 

Anyone come across this problem? Got any ideas on what I can do here? The simpler the better but I am not shy on doing coding if that's what it takes.

 

Further Information: I actually have more than one ActionSupport enabled InputText in this PageBlockSection, each with its own individual method attached. All work fine but are likewise not called if the Save button is immediately pressed. The methods are mutually destructive so I can't simply call them all as part of the save process. I could have the save method call the correct one if I had a way of determining which specific InputText was the one that was edited (assuming, of course, the just changed value of discountText is actually passed back to the Extension—might go System.Debug that to have a look).

 

 

Please could you help us

 

We need to calculate school year from dob.  eg if the child is born 27/08/2007 then it should calculate as year 1.  If the child is born on 01/09/2005 then it should calculate year 2.  In the UK the cut off date is 31st August so that the youngest in year 1 is born 31st August 2007, and oldest is born 01/09/2006.

 

The code we have for excel is 

=INT((TODAY()-A14+223+(MOD(YEAR(A14),4)=0))/365.25)-5 doesn't work properly as it appears to work for jan to jan year groups

 

 

In words the formula would be:-

 

(todays date - dob + (next sept date-todays date))/365.25 - 5

 

any help on this would be appreciated

 

Thanks

Is there any concept that on Execution of insert/update/delete Trigger on detail object, their Master Obejct's trigger get executed ? ( Even we do not Apply
any DML on Master Object in detail's trigger)

Hi guys,

 

Still a noob with APEX so any help will be very appreciated.

 

My requirement is that I need to insert an OLI to a new Opportunity created with a certain criteria (depending on record type).

 

The pricebook/product will always be the same.

 

Thanking you guys in advance!

 

 

regards,

 

DG

  • March 12, 2013
  • Like
  • 0

VFで繰り返し表示はapex:repeatを使うと思いますが、カスタムオブジェクトの子オブジェクトを繰り返し表示する際のコーディングで困っています。

知っている人は教えてもらえると助かります。

 

カスタムオブジェクト: A

子オブジェクト: B

 

上記で、

<apex:repeat value="{!A.B}" var="line">

とやるとエラーになります。やり方を教えてください。

Hello,

 

I have a 2 lists which i want to display alternatively.

My code is 

 

<apex:repeat value="{!questionsList}" var="section">
<apex:variable var="rlists" value="{!section.rlistss}"/>
<apex:variable var="i" value="{!0}"/>
<apex:repeat value="{!section.qlistss}" var="qlist">
<apex:outputField value="{!qlist.Question_Label__c}" />
<apex:outputField value="{!rlists[i].Response__c}" /> <!--This doesnt workhow to iterate this also after each question display 1 response-->
<br> </br>

</apex:repeat>

 

 

Thanks

  • January 29, 2013
  • Like
  • 0

I recently recreated my opportunity page layout using a visualforce tabbed panel. I would like to be able to display the number of related quotes on the quotes tab but I can't see to get it to work correctly. It seems like I have all the pieces so I'm not sure what I'm doing wrong. I am using the standard oppty controller with the following controller extension.

 

public class IntOppCon {
private Integer RelatedQuotes;
private Opportunity Opp;
public IntOppCon(ApexPages.StandardController controller) {
this.Opp= (Opportunity)controller.getRecord();
}

public Integer GetRelatedQuotes()
{

RelatedQuotes = [Select count() FROM Quote where Opportunityid = :opp.id];

return RelatedQuotes;

}
}

 

My visualforce page snippet works when I type is like this:

 

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes","Quotes (0)")}" name="Quotes" id="tabquote"

 

BUT the system starts to error out when I do it the way I would like which is like this:

 

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes (RelatedQuotes)","Quotes (0)")}" name="Quotes" id="tabquote"

OR

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes ({!RelatedQuotes})","Quotes (0)")}" name="Quotes" id="tabquote"

 

Can anyone help?

This is on the sandbox and I can't figure out why this trigger test isn't firing. All system debug get hit and have the correct data, System.debug('@@@ trgInsertNote');

 

trigger trgInsertNote on Note (after insert) {
    
    System.debug('@@@ trgInsertNote');
    BMCServiceDesk__Incident__c toUpdate = new BMCServiceDesk__Incident__c();
    
    for(Note n : Trigger.New){
        String nName = n.ParentId;
        String iName = Schema.getGlobalDescribe().get('BMCServiceDesk__Incident__c').getDescribe().getKeyPrefix();
        
        if ( nName.startsWith(iName) && !n.IsPrivate ) {
            
            toUpdate = [SELECT X3Ci_Last_Note__c FROM BMCServiceDesk__Incident__c WHERE Id = :nName][0];
            if ( n.Body == '' || n.body == null )
                toUpdate.X3Ci_Last_Note__c = n.Title;
            else
                toUpdate.X3Ci_Last_Note__c = n.Title + ': ' + n.Body;
        }
    }
    
    if ( toUpdate != null)
        update toUpdate;
}

 

@isTest(SeeAllData=true) 
public with sharing class TestTrgInsertNote{
    private static TestMethod void testInsertNoteMethod(){
        
        Profile cvProfile = [select id from profile where name = 'Standard User' limit 1];
        User usrCV = new User();
        usrCV.LastName='Test Client Value';
        usrCV.Username='dsfg@gmail.com23453245';
        usrCV.Alias='tesy07';
        usrCV.Email='sdfg@sdfg.com';
        usrCV.CommunityNickname='Test CV Contact';
        usrCV.TimeZoneSidKey='America/Los_Angeles';
        usrCV.localesidkey='en_US';
        usrCV.EmailEncodingKey='ISO-8859-1';
        usrCV.LanguageLocaleKey ='en_US';
        usrCV.ProfileId=cvProfile.id;
        usrCV.IsActive = true;
        Insert usrCV;
        System.debug('@@@ TestTrgInsertNote.usrCV: ' + usrCV);
        
        BMCServiceDesk__Incident__c testIncident = new BMCServiceDesk__Incident__c();
        testIncident.Subject__c = 'Test Incident';
        testIncident.BMCServiceDesk__FKClient__c = usrCV.Id;
        insert testIncident;
        System.debug('@@@ TestTrgInsertNote.testIncident: ' + testIncident);
        
        Note newNote = new Note(Title='Test title', Body='Test body', ParentId = testIncident.Id, IsPrivate = false);
        System.debug('@@@ TestTrgInsertNote.newNote: ' + newNote);
    }
}

 

  • December 31, 2013
  • Like
  • 0

There are 3 objects:

 

1. Quote: Standard Object

2. Quote Line Item: Standard object

3. BOQ Item: Custom object.

 

 

i>  BOQ Item is in a Master Detail relationship with BOQ. BOQ Item is detail object in the relationship.

ii> BOQ is in a look up relationship with Quote Line Item.

iii> There is a picklist field in the Quote Line Item called Rate Basis.

iv> I have created a formula field in the BOQ Item with the following formula:

Text(BOQ__c.Quote_Lookup__r.Rate_Basis__c)

 

There are no errors in the formula but at the same time no value is getting displayed.

 

 

What could be the problem?

Kindly help

 

Abhijeet

This is my code to simpy update a field on custom object from the task. I have never written a test class so please help me out to compose it.

 

trigger SandboxCC on Task (before update,after update) {

if(Trigger.isUpdate){

for(Task t : Trigger.new)
{

if(t.IsClosed == True && t.subject.contains('App Preview Sent to Customer'))
{
for(CC_Card__c c : [Select c.Id, c.stage__c From CC_Card__c c ])
{
c.stage__c = 'Preview & Iterate';
c.a_Preview_Date__c = system.today();
update c;
}

}

}
}
}

I have a picklist in salesforce and I need to have the options from that picklist as the options in a selectlist field.  How would I go about doing that?

I am new to this tech, So i am doing practise by myself by taking help from bloga and community.

 

I am trying to develop a Vf page having questions with it's answers having checkbox as prefirx.

 

e.g.

 

Question1- who is prime minister of india.

                       a- dr. Man Mohan Singh

                        b- Narendra Modi

                        c- Nitessh Kumar

                        d- lalu Yadav

 

Same Questin 2

 

 

I have created Questions and options as custom bjects in my org.

 

Could you please provide some help how to start working on it.

 

 

 

Thanks,

JaanVivek

                 

Hi,

 

I got a requirement to launch one of the Account list view by default, when Account tab is clicked. I able to redirect to the Account List view using the below visualforce content.

 

<apex:page action="{!URLFOR($Action.Account.List, $ObjectType.Account)}" />

 

However, I couldn't control the launch of dedicated List view by default; It shows me the last visited list view instead. I should not delete other Views to launch the expected View by default.

 

Can anyone help me to control the List view in visualforce page?

 

Regards,

SuBaa

  • October 10, 2012
  • Like
  • 0

Hi

 

  Interview question: In a visual force page by using standard controller  created a save button and one user wants to use that page by using extension and again creats a save button then can we get any error  in this situation ? Can anybody answer it for me?

Hi guys,

I got a problem with a script class that I'm using for refreshing dev sandboxes from production.
Class is based off https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm?edition=&impact= and it does a bunch of dml operations: 2 updates on users(disable non-admins and fix the '@example.com' for admins), 2 inserts with configuration records (for some custom objects that we are using) and another 5 inserts with normal test data (accounts, opps etc). It also sends a status email with details about operation (it should send it but it doesn't, I guess cause of the Email Deliverability setting on the Sandbox).

I start the refresh with the class selected and autoactivation and I get the email with the ""SanboxAfterRefreshHandler" apex class run finished. Check debug logs for stack trace". Very nice and quaint. 
Problem is only the user dml operations finish successfully. 

1. How can I see why the rest isn't working when refreshing a sandbox?? (they work fine when testing with Open Execute Anonymous Window)
2. Where are the debug logs saved? Are they in production? Setup >Monitoring > Debug logs?
3. This begs the question: is the class executed at Production level? or at the refreshed sandbox level??
4. Can I send an email at the end with debug details? Is this affected by the Email Deliveratbility from the sandbox?

PS:
I'm testing right now by hand (deploy partially commented class to Prod, run the sandbox refresh with the class, check in the sandbox if it did what it should...) but this process is not efficient - it take a full day.
Also, the user deactivation dml takes a lot of time when running the test class for it, 10 minutes or something, just smth that I observed

Thank you and
Happy Monday!
Adrian
 
Hello all,

We have a partial implementation of the Single-Sign On in our Production. 
A few years ago it was activated and setup for integration to work with our Windows domain users. But the process was not completed, the users did not get their Federation Ids in place, and because of that we are getting some errors right now.

For example: when users click a Salesforce link received by email, or in the chatter desktop app, or when the SFDC session expired they do not get the default login page thats provided as standard in Salesforce(login.salesforce.com). They get an error page because the Single-Sign On failed automatically and they do not know how to work around it. 

My questions are:
1. Can we safely disable this partial implementation of SSO? (Go to Setup> Single-Sign On Settings> Edit SAML Enabled and set it to false) 

2. We also have My Domain activated for this instance. This also appears in all emails sent, in all the links. Can we change it back to the simple login.salesforce.com? If we disable SSO is the url going to change?

3. In the future we are going to unify our Windows domains and we'll probably want to enable and have SSO functional. 
Can we have Single-Sign On for multiple user domains? Is this dependant on Salesforce or on the SAML server? 

4. If we keep SSO can we have the normal login.salesforce.com page for the non-domain users? Like the chatter users

Any idea or help is greatly appreciated :) , we do not have too much experience with SSO and Salesforce Support has redirected us here, cause it is a dev problem and they don't deal with those

Thanks and Happy Friday!
Adrian

Hi guys,

 

Got a small custom VF page for modifying account data. It's actually a big apex:form with a pageblock inside. Fields are grouped using apex:pageBlockSections. 

 

I've got 2 problems with it.

 

1. in one section I have a multiselect picklist fields with an actionsupport that "should" rerender another blocksection with some attachments.

Selected_Services__c is the picklist. 

<apex:page standardController="Account" extensions="AccountStatusChangeController" action="{!checkAttachments}" >	

	<apex:form id="theform" >
			  		
	        <apex:pageMessages />
	        
	        <apex:pageBlock title="Account {!account.Name}" >
	        	...
	        	<apex:pageBlockSection id="w9" columns="2" title="More Information" rendered="{!account.Status__c<>'LIVE'}" >
	        		...
	        		<apex:inputField value="{!account.Selected_Services__c}" required="true" label="Selected Services" >
	                	<apex:actionSupport event="onchange" reRender="attachments" immediate="true" /><!--  action="{!saveAccountModifications}"   -->
	                </apex:inputField>
	            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Attachments" columns="1" id="attachments" rendered="{!account.Status__c<>'LIVE'}" >
            	<apex:outputPanel rendered="{!account.Selected_Services__c<>null}" style="color:red;font-weight:bold" >
            		<br/>Please upload the following files: <br/>
            	</apex:outputPanel>
            	
            	<apex:outputPanel rendered="{!OR(CONTAINS(account.Selected_Services__c,'Programmatic Buying'),CONTAINS(account.Selected_Services__c,'Programmatic Selling'),CONTAINS(account.Selected_Services__c,'Ad Serving'),CONTAINS(account.Selected_Services__c,'ATM Buy'),CONTAINS(account.Selected_Services__c,'ATM Sell'),CONTAINS(account.Selected_Services__c,'ATM Buy/Sell'),CONTAINS(account.Selected_Services__c,'RTB'))}" >
           			<apex:outputText value=" - Self-service Contract" />
           			<br/>&nbsp;&nbsp;&nbsp;
           			<apex:commandLink value="Attach Self-service Contract" action="{!uploadServiceContract}" style="color:{!IF(serviceAttached='true','green','red')};font-weight:bold" />
           		</apex:outputPanel>
           		...
           	</apex:pageBlockSection>
           	
           	<apex:pageBlockButtons id="buttons" location="bottom" rendered="true" ><!-- shown all the time on the page -->
	            <apex:commandButton value="Submit Account For Approval" action="{!submit}" rerender="theform" /> 
	            <apex:commandButton value="Cancel" action="{!cancel}" />
            </apex:pageBlockButtons>
			            
        </apex:pageBlock>
        
         
    </apex:form> 
    
    
</apex:page>		

 

2nd problem is with some links that I have in the page. There are a New Contact apex:commandlink and also 3 links for uploading new attachments. These have actions with PageRefences that load other pages. On leaving the main form I save the modifications that the user has done to the form(most of the fields are required so I use immediate="true"). I've put a System.debug before the update account line and all the fields that have been modificated don't have the correct values. 

Let say BillingStreet is blank. User comes on the page and inputs it, then clicks the link to create a new Contact. Before returning the NewContact page the method saves the account, but!! Billing Street is still blank!! WTH?!

<apex:page standardController="Account" extensions="AccountStatusChangeController" action="{!checkAttachments}" >	

	<apex:form id="theform" >
			  		
	        <apex:pageMessages />
	        
	        <apex:pageBlock title="Account {!account.Name}" >
	        	
	        	<apex:pageBlockSection id="address" columns="2" title="Address" rendered="{!account.Status__c<>'LIVE'}" >
              		...
              		<apex:inputField value="{!account.BillingStreet}" required="true" />
              	</apex:pageBlockSection>	
\
            <apex:pageBlockSection id="w9" columns="2" title="More Information" rendered="{!account.Status__c<>'LIVE'}" >
                <apex:pageblocksectionitem >
                	<apex:outputLabel value="Finance/Billing Contact" for="FinanceContactName"  />
	                <apex:outputPanel style="text-align:center" >
	                	<apex:inputText id="FinanceContactName" value="{!financeContactName}" label="Finance/Billing Contact" styleClass="" />
	                	<apex:inputHidden value="{!financeContactId}" id="hiddenFinanceContactId" />
	                	<a title="Search" onclick="window.open('/apex/CustomContactLookup?name={!$Component.FinanceContactName}&cid={!$Component.hiddenFinanceContactId}&id={!accountId}','Search','width=500,height=400')" >
							<img class="lookupIcon" onmouseover="this.className='lookupIconOn';this.className='lookupIconOn';this.style.cursor='pointer';" onmouseout="this.className='lookupIcon';this.className='lookupIcon';" onfocus="this.className='lookupIconOn';" onblur="this.className='lookupIcon';" alt="Search" src="/s.gif" />
						</a>
						<apex:commandLink value="New" action="{!createNewFinanceContact}" />
	                </apex:outputPanel>
                </apex:pageblocksectionitem>

 

public void saveAccountModifications() {
    	try{
    		System.debug('before account has this value: ' + account);
    		account.Finance_Billing_Contact__c = financeContactId;
            update account;
            System.debug('account updated succesfully!');
            account = [SELECT Id, Name, Status__c, Requested_Account_Status__c, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, 
	        			Selected_Services__c, Final_Signed_Agreement__c, Finance_Billing_Contact__c, Credit_Application__c, First_User__c, Account_Director__c, Senior_Client_Services_Lead__c, 
	        			Management_Override__c, (SELECT Id, Name, Description FROM Attachments), Finance_Billing_Contact__r.LastName, Finance_Billing_Contact__r.FirstName, Currency_Selection__c 
	        			FROM Account WHERE Id =: accountId LIMIT 1];//(SELECT Id, IsNote, Title, Description FROM NotesAndAttachments)
	        System.debug('account has this value: ' + account);
        } catch(Exception e) {
        	System.debug('account update failed: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Unable to update account '+e.getMessage()+e.getStackTraceString()));
        }
    }
 	
 	public PageReference createNewFinanceContact() {
 		saveAccountModifications();
 		return new PageReference('/apex/CustomContactCreate?accid=' + account.Id);	
 	}

 

 

I have this nagging feeling that I'm missing something simple :(. Hmmm, if anyone wants I'll add the full page and controller here.

 

Thank you,

Adrian

 

 

 

 

 

 

 

 

Hello guys,

 

I need a little help.

 

I have a bug that goes like this: when the user edits an input field in an apex:repeat, and keeping the focus on the input goes with the mouse and clicks directly the Save button, only 1 ajax call is sent to the server, the one for the actionsupport of the inputField. Shouldn't 2 POSTs be made? one for the actionsupport that rerender a part of the table, and one for the {!save} action?

 

VF:

<apex:form>
	...
	<apex:commandButton action="{!save}" value="Save" rerender="existingProductsBlock,summaryTable,newProductsBlock" status="status" />
	...
	<apex:pageBlock>
		<apex:repeat value="{!fwrapper.wrapperList}" var="wrapper" >
			...
			<apex:outputPanel id="quantity" rendered="{!wrapper.isSelected}">
	   			<apex:actionRegion >
	                <apex:inputText value="{!wrapper.quantity}" style="width:30px;" onkeyup="return validate_qty(this);" >                                                                                                  
	                	<apex:actionSupport event="onchange"   reRender="existingProductsBlock" status="status"/>
	                </apex:inputText>
	            </apex:actionRegion>
	        </apex:outputPanel>
	        <apex:outputPanel id="quantity2" rendered="{!NOT(wrapper.isSelected)}">
	       		<apex:outputText value="{!wrapper.quantity}" style="width:30px;"  />
	        </apex:outputPanel>
	        ...

 The actionsupport is needed to rerender the list. This is because some fields influence the values of others, for example modifying quantity needs to modify the year1 values. 

public Decimal quantity							{
    		get; 
    		set {
    			if (quantity == value) {
    				return;
    			}
    			quantity = value;
    			if (quantity == null) {
    				quantity = 0;
    			}
    			if (listPrice == null) {
    				listPrice = 0;
    			}
    			if (discount == null) {
    				discount = 0;
    			}
    			year1 = listPrice*quantity*(100-discount)/100;
    			year2 = year1;
    			year3 = year1;
    			year4 = year1;
    			year5 = year1;
    			year6 = year1;	
    		}
    	}

 

So, in the page, when the user modifies a value, AND doesn't click anywhere else on the page, as in the cursor doesn't leave the input, BUT he goes directly to the save button, only the setting of that field occurs. The user needs to click again the save for it to occur...

 

Also, since the list of records is pretty large, or the instance is slow, idk, the setters are kinda slow. Setting a value, and waiting for the dependent fields to be modified in the controller takes some time. Is there some way to move this dependency logic in the client(javascript maybe?) so that the controller is not called on every input change?

 

Thank you,

Adrian

 

Hello guys,

 

I'm in need of a little help.

 

I got an assignment to make a generic rails page from which any user can insert records into SFDC. 

There must be 2 pages, one available to an admin, like a control panel to set the required sObject for the form and easily add sfdc credentials, and another page to actually insert the record.

The form will be dynamic, ie it will change the fields depending on what sfdc has. I'm thinking this can be done through sObject describe calls, to get the metadata and construct the model from there...

 

As for the gem used to connect to SFDC, what do you suggest using, rforce or ActiveSalesforce? I must admit that I'm new to Ruby and RoR so I'm open to sugestions. :)

 

Has anyone done smth similar or do you know any examples on how to do this? 

Any bit or link helps.

 

Thanks!

Adrian

Hello,

 

I have a small logical problem with a VF page. At least that's what I think it is - a bad design from my part.

 

The page shows a List<Wrapper>. The Wrapper inner class has a bunch of Decimal fields, all public and with {get; set}. Some are editable in the page, while others are read-only, summaries for the other fields.

public class Wrapper {
    	
    	public Decimal quantity							{
    		get; 
    		set {
    			quantity = value;
    			
    			year1 = listPrice*quantity*(100-discount)/100;
    			year2 = year1;
    			year3 = year1;
    			year4 = year1;
    			year5 = year1;
    			year6 = year1;	
    		}
    	}
    	public Decimal listPrice						{get; set;}
    	public Decimal year1;							
    	
    	public Decimal getYear1() {
    		return year1;
    	}
    	
    	public void setYear1(Decimal value) {
    		this.year1 = value;
    		this.year1Discount = (quantity*listPrice - year1)/(quantity*listPrice) * 100;
    	}
    	
    	public Decimal year2							{get; set;}
    	public Decimal year3							{get; set;}
    	public Decimal year4							{get; set;}
    	public Decimal year5							{get; set;}
    	public Decimal year6							{get; set;}
    	
    	public Decimal discount;
    	
    	public Decimal getDiscount() {
    		return discount;
    	}
    	
    	public void setDiscount(Decimal value) { 
    		this.discount = value;
			year1Discount = discount;
			year1 = quantity*listPrice*(100-discount)/100;
			year2 = year1;
			year3 = year1;
			year4 = year1;
			year5 = year1;
			if (this.isNew) {
				year6 = 0;
			} else {
				year6 = year1;	
			} 
    	}
    	public Decimal year1Discount					{get{ return (quantity * listPrice - year1)/(quantity * listPrice) * 100;} set;}
    	
        public Decimal total							{get{ return (year1 + year2 + year3 + year4 + year5 + year6).round();} set;}
    	
        public Wrapper() {
        	
        }
}

As you can see, setting the quantity will change year1 to year6, same for discount. Setting year1 will modify year1Discount.

And total will always return the sum of year1+.. year6.

 

In the page only quantity, year1-year6 and discount are editable(based on a checkbox), while listPrice, discount and year1Discount are not.

 

The page looks like this(or at least a fragment of it):

<apex:pageBlock id="newProductsBlock">
	<apex:repeat value="{!fwrapper.wrapperList}" var="wrapper" >
		<tr >
			<td> 
			    <apex:inputCheckbox value="{!wrapper.isSelected}" >
			        <apex:actionSupport event="onchange" action="{!recalculate}" reRender="newProductsBlock, summaryTable"/>
			    </apex:inputCheckbox>
			</td>
			<td>
				<apex:outputPanel rendered="{!wrapper.isSelected}">
			        <apex:inputText value="{!wrapper.quantity}" >                                                                                                  
			        	<apex:actionSupport event="onchange" action="{!recalculate}" reRender="newProductsBlock, summaryTable" />
			        </apex:inputText>
				</apex:outputPanel>
				<apex:outputPanel rendered="{!NOT(wrapper.isSelected)}">
				    <apex:outputText value="{!wrapper.quantity}" />
				</apex:outputPanel>
			</td>
			<td>
				<apex:outputPanel rendered="{!wrapper.isSelected}">
					<apex:inputText value="{!wrapper.year1}" >
				   		<apex:actionSupport event="onchange" reRender="newProductsBlock, summaryTable"/>    
					</apex:inputText>
				</apex:outputPanel>
				<apex:outputPanel rendered="{!NOT(wrapper.isSelected)}">
					<apex:outputText value="{!wrapper.year1}" />
				</apex:outputPanel>   
			</td>
			<!-- rest of the years 2 - 6 -->
			<td class="borderClass">
             	<apex:outputText value="${0,number,#,###,###,###,###,##0}">
             		<apex:param value="{!wrapper.total}"/>
             	</apex:outputText>
            </td>	
            <td class="borderClass">
				<apex:outputPanel rendered="{!wrapper.isSelected}">
					<apex:inputText value="{!wrapper.discount}" >
				   		<apex:actionSupport event="onchange" reRender="newProductsBlock, summaryTable" status="status"/>    
					</apex:inputText>
				</apex:outputPanel>
				<apex:outputPanel rendered="{!NOT(wrapper.isSelected)}">
					<apex:outputText value="{!wrapper.discount}"/>
				</apex:outputPanel>  
			</td>

			<td class="borderClass">
				<apex:outputText value="{0, number,##0.00}%">
					<apex:param value="{!wrapper.year1Discount}"/>  
				</apex:outputText>                                   
			</td>	

 

My Problem is that whenever I type in another value for year1 let's say, the pageBlock is refreshed and the year1-year6 values are computed based on discount(it's the last inputText in the table), my inputed value is lost.... Somehow the discount setter is called and this "locks up" the values for the other fields... I don't know if this is the standard functionality but I need to find a way to:

  1.  on load of page show the same values as extracted from the DB without any logic on them- ie no relations between fields
  2. changing the quantity or discount recomputes all the year1-6 values
  3. changing the year1 to year6 values modifies only the total -> here is the mind fart, right now my design will change the value based on the discount and not keep the new value....

 

Wrapping the inputtexts for the year1 to year6 in apex:actionRegions seems to do what I want, yearx keeps the value, total is recalculated. However, the value is not saved in the List<Wrapper> in the controller... when I call the method to save to DB the List, this has the old values(the new value for yearx is not present)...

 

Should I try to remove those calculations from the setters of the Wrapper? I donno, for example create a calculateDiscount() method in the controller... but how do I modify only those rows where a new discount has been inputed?

 

I feel I'm close to a solution, and maybe if I get a little sleep and food I'll see it clearer, but I wouldn't say no to any help or suggestion :)

 

Happy Tuesday!

A.

Hello all!

 

So, here's my problem: I have a VF page with a custom controller. Inside the page I'm rendering a Map<String, List<Wrapper>> using 2 repeats, where Wrapper is an inner class built around the OpportunityLineItem object. It looks like this: 

public class OpportunityLineItemWrapper {
        public OpportunityLineItem lineItem             {get; set;}
        
        public Boolean isSelected			{get; set;}
        public Boolean productHasWSCASelected		{get; set;}
        public Decimal year1Discount				{get; set;}
        public Decimal total						{get; set;}
        public String productName					{get; set;}
        public String productId						{get; set;}
        
        public OpportunityLineItemWrapper() {
            lineItem = new OpportunityLineItem();
            isSelected = false;
            productHasWSCASelected = false;
            year1Discount = 0;
            total = 0;   
            productName = ''; 
            productId = ''; 
        }
        
    }

 

isSelected is used in the VF page make the whole wrapper record editable or not. It's a checkbox that I'm using to rerender the pageBlock for the map and make some fields editable when checked.

<apex:pageBlock title="test the map null thingie" id="tst">  
        <table>          
            <apex:repeat value="{!existingLineItemsMap}" var="family" id="repeat">
            	<tr>
             	    <td colspan="15">
                    	{!family}
                    </td>
                </tr> 
                <apex:repeat value="{!existingLineItemsMap[family]}" var="wrapper" rendered="{!family <> null}">
	            	<tr> 
                	<td class="borderClass">                            
                            <apex:actionRegion >
                            	<apex:inputCheckbox value="{!wrapper.isSelected}">                                     
                                	<apex:actionSupport event="onchange" action="{!recalculateSummaryTable}" reRender="tst" status="status" />
                                </apex:inputCheckbox> 
                                
                             </apex:actionRegion>            
                        </td>
                        <td class="borderClass">
                         	<apex:outputLink value="/{!wrapper.productId}" id="theLink" target="_blank" >
                         		{!wrapper.productName}
                         	</apex:outputLink>
                         </td>
                     </tr>
                  </apex:repeat>
               </apex:repeat>
           </table>
       </apex:pageBlock>

 recalculateSummaryTable doesn't modify the map in any way, I've put System.debugs at the begining and at the end of it and the map has the same value.

 

The problem is when I click in the page one of the checkboxes I'll get an error:

Visualforce Error

Map key null not found in map
Error is in expression '{!existingLineItemsMap[family]}' in component <apex:page> in page addproductsform2

I really don't get it what null value is it seing. The debugs show a 'good' map...

 

 I'm wrecking my brains for about 2 days on this one :( and I still haven't managed to solve it!!! Any suggestion is highly apreciated if you can help me please.

 

Thanks,

Adrian

Hi all!

 

Just a couple of quick questions guy, if you can help me...

 

1. is there a way in apex when converting a Lead with convertLead DML to not create a contact? I just want the account and the oppty, no contact. Is this possible through config?

 

2. when setting the Account id and Contact id for a merge, with setAccountId() and setContactId() how does the merge function? Is it an update call on those 2 records? Are only the fields from the mapping copied over? 

 

3. Can I manually convert a Lead in apex code, without using convertLead? I'm thinking of manually creating the Acc and Oppty from it and then updating the ncessary fields on the Lead, like 

  • ConvertedAccountId
  • ConvertedDate
  • ConvertedOpportunityId
  • IsConverted
  • Status

Is this possible?

 

4. Is there any way to modify the convert page? I would like to give the user the choice of creating a new Account of a certain RecType, merging with an existing one(and only copy over some fields) or search an external service for an existing  Account and copy the info for it from there...( :) I know, I want a lot!)

 

Thanks,
Adrian

Hello all!

 

I have a problem with the Force.com IDE. The line numbers on the text editor are not refreshing! If I scroll down the code scrolls corectly, but the line numbers remain the same... This is pretty annoying as I spend most of my time in the ide.

LINK1

LINK2 and LINK3

 

I have OS X 10.8.0 with Force.com IDE Summer '12 (25.0.0).

 

I've found some similar problems on the net for Eclipse, but not specifically for Force.com IDE. If anyone knows how to resolve this I would really appreciate it.

 

Thank you,

Adrian

Hello all,

 

I'm doing a webservice method that has a soql in  it. I have a Resource Assignment object which has 2 Lookups, one to Project and one to Resource. I'm querying fields from both of them with smth like this:

webservice static String getProjectsJSON() {
		List<Resource_Assignment__c> raList = [SELECT Id, Name, Amount__c, Start_Date__c, End_Date__c, Project__r.Name, Resource__c, Resource__r.Name, Resource__r.Start_Date__c, Project__r.Stage__c FROM Resource_Assignment__c WHERE Start_Date__c=NEXT_N_DAYS:150 AND End_Date__c=NEXT_N_DAYS:150];
		System.debug('raList has this value: ' + raList);
...

 The problem is I cannot access the fields from the lookups. 

 

for (Resource_Assignment__c ra: raList) {
    String name = ra.Resource__r.Name;
    ....
}

Trying to access for example Resource__r.Name will give me an error that there's no such field on the Resource Assignment object.

 

In the debug log I get the following: 

|VARIABLE_ASSIGNMENT|[40]|raList|[{"Name":"RA - 0018","Project__r":{"Name":"Test Proj 1","Id":"a00E00000037WihIAE"},"End_Date__c":"2012-08-01T00:00:00.000","Project__c":"a00E00000037WihIAE","Resource__r":{"Name":"Marius B","Id":"a02E00000028m9pIAA","Start_Date__c":"2012-06-05T00:00:00.000"},"Resource__c":"a02E00000028m9pIAA","Id":"a01E000000At2WUIAZ","Start_Date__c":"2012-07-19T00:00:00.000","Amount__c":11},.....

 However when I show the list using System.debug I only get this:

|USER_DEBUG|[43]|DEBUG|raList has this value: (Resource_Assignment__c:{Name=RA - 0018, End_Date__c=2012-08-01 00:00:00, Project__c=a00E00000037WihIAE, Id=a01E000000At2WUIAZ, Resource__c=a02E00000028m9pIAA, Start_Date__c=2012-07-19 00:00:00, Amount__c=11}, ....

 

So... anyone has any idea what I'm doing wrong?

I checked the field visibility, sharing rules etc. I run this as sys admin so there shouldn't be any reason why those fields are not visible/retrieved/whatever... :(

 

Thank you,

Adrian 

 

 

HI ,

Find accounts which are enabled as partner user  and doesn't have partner user ?
 
Hi,

Can  any body tell me the difference betwen the getvalues() and getinstance () methods  customsettings.


Regards,
Siva.
Consider, if we have attachment added to "Quote" object and we need to generate "order" object record from attached quote PDF based on trigger or anything.

Is it possible in salesforce to read the PDF and generate record from it?
Up to my knowledge there is no way in Apex to do the same or by any way we can implement the same.

Let me know if you have any sugesstions for the same. 
Hi guys,

I got a problem with a script class that I'm using for refreshing dev sandboxes from production.
Class is based off https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm?edition=&impact= and it does a bunch of dml operations: 2 updates on users(disable non-admins and fix the '@example.com' for admins), 2 inserts with configuration records (for some custom objects that we are using) and another 5 inserts with normal test data (accounts, opps etc). It also sends a status email with details about operation (it should send it but it doesn't, I guess cause of the Email Deliverability setting on the Sandbox).

I start the refresh with the class selected and autoactivation and I get the email with the ""SanboxAfterRefreshHandler" apex class run finished. Check debug logs for stack trace". Very nice and quaint. 
Problem is only the user dml operations finish successfully. 

1. How can I see why the rest isn't working when refreshing a sandbox?? (they work fine when testing with Open Execute Anonymous Window)
2. Where are the debug logs saved? Are they in production? Setup >Monitoring > Debug logs?
3. This begs the question: is the class executed at Production level? or at the refreshed sandbox level??
4. Can I send an email at the end with debug details? Is this affected by the Email Deliveratbility from the sandbox?

PS:
I'm testing right now by hand (deploy partially commented class to Prod, run the sandbox refresh with the class, check in the sandbox if it did what it should...) but this process is not efficient - it take a full day.
Also, the user deactivation dml takes a lot of time when running the test class for it, 10 minutes or something, just smth that I observed

Thank you and
Happy Monday!
Adrian
 
H iall

Aware this is a bit of an odd request but I was wondering if anyone can help.  I use salesforc ein a primary school so we can't afford the developer costs associated with normal salesforce use case development but was hoping that someone might be able to help me do something.  Basically I (a certified admin) need to create someway of scanning information from a template which lists students in a class and denotes whether they are present or not (morning attendance).  The sheets list all the studenmts names and their student ID along with a box filled in for absent or present.  If its left black they are present.  This sheet is fully typed and printed but the penciling in denotes if theres an absense.  Basically I want to find a way to scan these attendance sheets into salesforce and have a record created for each student to record their attendance situation for the day.  The sheet is the same each day for each class.  it just needs to record the date, student idf and the attendance for each student once a day. 

I am aware there is a 3rd party system that can do this but its so expensive per year.  I see that there are APIs that can help with this and set areas for partial recognition areas but I have no idea how to do this at all.  I was looking at http://ocrsdk.com/documentation/apireference/ and http://www.online-code.net/ocr.html.

If anyone thinks they can help or make this process kind of idiot proof for me I'd really appreciate it.  I know what I need to do once the data is collected in salesforce but its just getting it from the sheet into tthe system.  Its seriously just for kids attednance to be recorded so we can find out where they are or why they are not somewhere as quickly as possible and maki ng alerts using workflows etc.  The impact of this would be huge.  any help or expertise much appreciated.  I do believe for someone who knows what they are doing this might not be super hard.  
Hi all,

Here is some very basic before insert code I am using in an account trigger - my intent is to copy the OwnerId (or OwnerName) to a text field called Original_Account_Owner__c. This field would retain a historical record of who the original account owner was so that we can always report on that data even if the current owner is changed.
 
if (Trigger.isBefore && Trigger.isInsert) {
        for(Account acct : Trigger.new){
            // Check that the owner is a user (not a queue)
            if( ((String)acct.OwnerId).substring(0,3) == '005' && acct.Original_Account_Owner__c == null ){
            acct.Original_Account_Owner__c = acct.OwnerId;
            }
            else{
            // In case of Queue (which shouldn't happen), System Debug.
            System.debug('found a queue when we shouldn't have...' + acct.OwnerId);
            }
        }

This works perfectly if I convert a lead for myself, with myself set as the Record Owner during the conversion process...

However:
If I have two employees (Emp A and Emp B) and Emp A is converting a lead but during the conversion process he/she sets the Record Owner to Emp B, the end result after my trigger runs is that the "Original Account Owner" is showing Emp A and the "Account Owner" is showing Emp B when in reality I want the "Original Account Owner" and the "Account Owner" to BOTH be Emp B because that was the Record Owner selected during the conversion.

My assumption was that if the record owner is selected during conversion, it would be the one that the new account record is created with - so my trigger should just pick up the Account Owner prior to insert and set it on my custom field... instead, it looks like it assumes that I am the Record Owner during insert and then quickly changes it afterwards?

Is there any way I can combat this and get the end result I am looking for, or am I stuck because of the nature of the account creation/reassignment process during conversion?

Many thanks for your input everyone!
I am still relatively new to developing VisualForce pages and customer controllers.  I would like to retrieve fields from a form and then pass the values to a webservice.  When I click on the actionFunction, the method is executed.  The form values are reset to blanks (at one time they stayed on the form).  I can see the debugtxt flash up on the screen before it is reset to blanks as well.  I would like for the form fieldss to not be blanked out, so I think this is a rerender issue.

VisualForce Page
<apex:page controller="Product_UsersController" sidebar="false" >
<apex:form >
<apex:pagemessages id="errors" />

    <apex:pageBlock title="Search" id="edit">   
    
    
    
    <table border="2" style="width:100%;">
    <tr>
    	<td style="font-weight:bold;width:200px;">
    		Find Product Users
    	</td>  
    	<td>
    		Filter Options: 
    		<input type="checkbox" name="chkShowRequesters" />Show Requesters
    		<input type="checkbox" name="chkShowAdministrators"/>Show Only Administrators
    	</td>
    </tr>
    </table>
    
    <table border="2" style="width:100%;">
    <tr>
    	<td style="width:200px;valign:top;border:1;">
    		<apex:pageBlock mode="edit" id="parameters">
    
    <script type="text/javascript">
    
    function getParameters() 
    {
    	try
    	{
    	
    	passVariables(
    		"SD",
    		"MD",
    		document.getElementById("txtFirstname").value,
    		document.getElementById("txtLastname").value,
    		document.getElementById("txtLoginname").value,
    		document.getElementById("txtEmail").value,
    		document.getElementById("txtCountry").value,
    		document.getElementById("txtCity").value,
    		document.getElementById("txtState").value,
    		document.getElementById("txtZip").value);
    	}
    	catch(err)
    	{
    		alert("getParameters Error: " + err.message);
    	}
    	
    }	  		
    </script>
    <apex:actionfunction name="passVariables" action="{!runSearch}" rerender="debug,errors">
    	<apex:param name="rbBusinessUnit" value=""  />
    	<apex:param name="slProduct" value="" />
    	<apex:param name="txtFirstname" value="" />
    	<apex:param name="txtLastname" value="" />
    	<apex:param name="txtLoginname" value="" />
    	<apex:param name="txtEmail" value="" />
    	<apex:param name="txtCountry" value="" />
    	<apex:param name="txtCity" value="" />
    	<apex:param name="txtState" value="" />
    	<apex:param name="txtZip" value="" />
    </apex:actionfunction>
    
    		<table border="2" cellpadding="2" cellspacing="2" width="200px">
    		<tr>
        		<td style="font-weight:bold;">Business<br />
            		<input type="radio" id="rbBusinessUnit" name="rbBusinessUnit" value="SD" checked="true" />SD 
            		<input type="radio" id="rbBusinessUnit" name="rbBusinessUnit" value="FD" />FD
        		</td>
    		</tr>
    		<tr>
        		<td style="font-weight:bold;">Product<br />
        	 		<apex:selectlist value="{!SDProducts}" id="slProduct"  size="1">
        	 			<apex:selectOptions value="{!SDProducts}" />
        	 		</apex:selectlist>
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">First Name<br />
        			<input type="text" id="txtFirstname" name="txtFirstname"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Last Name<br />
        			<input type="text" id="txtLastname" name="txtLastname"  />
        		</td>
    		</tr>
    		<tr>
    		    <td style="Font-weight:bold;">Login Name<br />
        			<input type="text" id="txtLoginname" name="txtLoginname"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Email<br />
        			<input type="text" id="txtEmail" name="txtEmail"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Country<br />
        			<input type="text" id="txtCountry" name="txtCountry"  />
       		 	</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">City<br />
        			<input type="text" id="txtCity" name="txtCity" />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">State<br />
        			<input type="text" id="txtState" name="txtState" />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Zip<br />
        			<input type="text" id="txtZip" name="txtZip" />
        		</td>
    		</tr>
    		<tr>
    			<td> 
    				
    				<button onclick="getParameters()">Search</button>
    				
    				<!-- <apex:commandButton value="Search" action="{!getParameters}" id="SearchButton" rerender="results,debug,errors" /> --> 
    			</td>
   			</tr>
    			  
    	</table>
    	</apex:pageBlock>  
    	</td>
    	</tr>
    </table>
    
     
    <apex:pageBlock title="Debug" id="debug">
      <apex:outputText value="{!debugtxt}" />           
    </apex:pageBlock>
    
	</apex:pageBlock>
</apex:form>    

</apex:page>

Custom Controller
public with sharing class Product_UsersController {
        
        
        public String debugtxt {get ;  set;    }
        public List<Product2> ProductTemp = new List<Product2>();
        public string selectedProduct {get; set;}
        
        public List<SelectOption> SDProducts 
        {
        	get 
        	{
        		ProductTemp = [Select p.SDProductID__c, p.Name From Product2 p 
        			where SDProductID__c > 'A' and Family like 'SD%'
        			order by p.Name];
        		SDProducts = new List<SelectOption>();
        		SDProducts.add(new SelectOption('','<== Optional Product ==>'));
        		for (Product2 temp : ProductTemp)
        		{
        			SDProducts.add(new SelectOption(temp.SDProductID__c, temp.Name));
        		}
        		return SDProducts;
        	  }
        	  set; }
        	  
//         public List<SelectOption> FDProducts 
//        {
//        	get 
//        	{
//        		ProductTemp = [Select p.SDProductID__c, p.Name From Product2 p 
//        			where SDProductID__c > 'A' and Family like 'FD%'
//        			order by p.Name];
//        		FDProducts = new List<SelectOption>();
//        		for (Product2 temp : ProductTemp)
//        		{
//        			FDProducts.add(new SelectOption(temp.SDProductID__c, temp.Name));
//        		}
//        		return FDProducts;
//        	  }
//        	  set; }
       
 
 		public Product_UsersController() {
 //			debugtxt = 'Complete search parameters and click run search to view selections';
 			system.debug('Entered Product_usersController');
 			
 		}
 		public  PageReference runSearch()  {
 			system.debug('***Entered runSearch function');
 			string rbBusinessUnit = apexpages.currentPage().getParameters().get('rbBusinessUnit');
 			string slProduct = apexpages.currentPage().getParameters().get('slProduct');
 			string txtFirstname = apexpages.currentPage().getParameters().get('txtFirstname');
 			string txtLastname = apexpages.currentPage().getParameters().get('txtLastname');
 			string txtLoginname = apexpages.currentPage().getParameters().get('txtLoginname');
 			string txtEmail = apexpages.currentPage().getParameters().get('txtEmail');
 			string txtCountry = apexpages.currentPage().getParameters().get('txtCountry');
 			string txtCity = apexpages.currentPage().getParameters().get('txtCity');
 			string txtState = apexpages.currentPage().getParameters().get('txtState');
 			string txtZip = apexpages.currentPage().getParameters().get('txtZip');
 			
 			
 			debugtxt = 'Business Unit: ' + rbBusinessUnit;
 			debugtxt = debugtxt + '; Product: ' + slProduct;
 			debugtxt = debugtxt + '; First Name: ' + txtFirstname;
 			debugtxt = debugtxt + '; Last Name: ' + txtLastname;
 			debugtxt = debugtxt + '; Login Name: ' + txtLoginname;
 			debugtxt = debugtxt + '; Email: ' + txtEmail;
 			debugtxt = debugtxt + '; Country: ' + txtCountry;
 			debugtxt = debugtxt + '; City: ' + txtCity;
 			debugtxt = debugtxt + '; State: ' + txtState;
 			debugtxt = debugtxt + '; Zip: ' + txtZip;
			system.debug('*** ' + debugtxt);
 			return null;
 		}
}

 
hi all,

I have a functionality wherein i need to use aepx:actionfunction and apex:param for an apex:outputlink
The problem:


<apex:column >
         <apex:outputLink value="/{!item.id}" target="_blank" onclick="callAcc();">
         {!item.name}
         <apex:param name="passid" value="{!item.id}"/>
         </apex:outputLink>
        </apex:column>
***********************************

 Id accid=ApexPages.currentPage().getParameters().get('passid');
        System.debug('**** new accountid is'+accid);


When i try to get the param passed in controller it fetches null.How do i fix it?

Thanks,
SFDC Coder
I have a trigger on opportunites that will add a field from a custom object (TSG__c)  if a match is found on .P21_Customer_ID.  The issue is that when multiple records are being updated through an upsert (Informatica Cloud) all of those opportunites are getting updated with the same field value.

Below is my trigger, please let me know where I went wrong.

Thanks again.


TRIGGER populate_TSG on Opportunity (before insert,before update) {

Set<string> ss = New Set<string>();
List<TSG__c> TheTSG=new LIST<TSG__c>();  
   
//Loop through all records in the Trigger.new collection
FOR(Opportunity O: Trigger.new)
{
    ss.Add(O.P21_Customer_ID__c );
}

TheTSG = [SELECT ID from TSG__c WHERE P21_CompanyCustomer_ID__c IN: ss];
   
    System.debug('@@@@--'+TheTSG.size());

    IF (TheTSG.size() >0)
    {
        For (Opportunity O: Trigger.new)
        {
            For(TSG__c tsg:TheTSG)
            {
               
           
            O.p21_account_number__c = tsg.ID;
            System.debug('@@@@--'+tsg.ID);
           
            }
        }
    }
}
Hi,

Iam having a trigger on a custom object which will update the checkbox to true if there is any attachment attached to the "Notes and Attachments" related list

But its not updating to true after attaching the record 


My Trigger

trigger Validate_attachment on Special_Programs_ADR_Exception__c (after insert) {
    List<id> AttachmentIds=New List<id>();
    Set<String> adrIdSet = new Set<String>();
    List< Special_Programs_ADR_Exception__c> updAdrList = new List< Special_Programs_ADR_Exception__c>();

     for(Special_Programs_ADR_Exception__c adr: Trigger.new){
                adrIdSet.add(adr.Id);
    }

    List<Attachment> notesList  =  [Select ParentId from Attachment where ParentId IN : adrIdSet];
   if(notesList!= null && notesList.size()>0){
                for(Special_Programs_ADR_Exception__c adr: Trigger.new){
                         adr.Attachments__c =true;
                          updAdrList.add(adr);
                               system.debug('list'+updAdrList);
               }
                                               
     try{
                Update updAdrList;
      }
       Catch(Exception e){
                 
   system.debug('Update failed'+ + e.getMessage());
    }
     system.debug('test'+updAdrList);

}
}


Let me know whats the issue on it


Thanks in Advance
I have created a formula to prevent user to edit record after fulfiling some creterias. My formula is :
AND( RealSteer__Offer__r.Agreement_Closed__c =True,
      ISPICKVAL(RealSteer__Status__c, 'Mounted'),( RealSteer__Offer__r.RealSteer__Close_Date__c >  RealSteer__Offer__r.RealSteer__Property__r.Revenue_Close_Date__c ),

OR(ISCHANGED( RealSteer__Offer__r.RealSteer__Account__r.Name),
     ISCHANGED( RealSteer__Offer__r.Name),
     ISCHANGED( RealSteer__Blocking_Start_date__c ),
     ISCHANGED( RealSteer__Blocking_End_date__c ),
ISCHANGED(  RealSteer__Offer__r.Category__c  ),
ISCHANGED( RealSteer__Offer__r.RealSteer__Property__r.Name  ),
ISCHANGED(  RealSteer__Offer__r.RealSteer__Status__c ),
ISCHANGED(  RealSteer__Offer__r.Owner_Name__c   ),
ISCHANGED( RealSteer__Offer__r.Payment_Terms__c ),
ISCHANGED(  RealSteer__Offer__r.Blanket_Approval__c ),
ISCHANGED(  RealSteer__Offer__r.Printing_Charges__c  ),
ISCHANGED(  RealSteer__Offer__r.Mounting_Charges__c  ),
ISCHANGED(  RealSteer__Offer__r.Other_Charges__c ),
ISCHANGED( RealSteer__Offer__r.RealSteer__Approval_Status__c),
ISCHANGED(  RealSteer__Offer__r.Approved_By_Accounts__c ),
ISCHANGED(  RealSteer__Offer__r.Approved_By_Sales_Co_ordinatior__c )
))

Can anyone help me out to solve this issue?

Hi All,

 

I am a complete novice to the development side, especially Apex and am trying to create a trigger that will 'roll-up' or sum a field from a child record and I can't use standard roll ups due to limits. I have found a lot of code that can help with normal roll ups but the tricky part of what I am trying to do is that the child records of a specific 'type' can only be counted once and there is also another requirement that a field on the child record can't be empty. And that field is only populated, by other code, after the record is inserted. 

 

So basically it's a child object linked to Accounts. When a child is updated, the trigger will need to check if a child record with a specific type already exists for that account. The 'type' field on the child object  is a picklist field. If it does NOT already exist then the field on accoints called points will need to be increased by 10.  If it does already exist then nothing will happen and the record will just be updated as normal. Also, there will need to be an after delete so that when a child record is removed and it is the only one of that type, 10 points will need to be removed from the field on accounts. 

 

I am probably over complicating it but does anyone out there have a similar code I could take a look at that would give me a good starting point?

 

Hi,

I have a doubt in webhooks integration. I have created a webhook between campaign monitor and salesforce using salesforce site URL. According to campaign monitor webhooks concept they will POST a HTTP request in the format of JSON when any of the campaign monitor subscriber changes his state, and I am able to get the request in salesforce debug Log, But I am unable to read that JSON data.

 

My site have a class to read that HTTP Post request which is coming from campaign monitor but in that I am getting status code 400. My class is

 

public class HttpCalloutSample2 {

  public String getContent() {

    Http h = new Http();

    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://MYSITEURL/");
    req.setMethod('GET');
    req.setHeader('Content-Length', '');
    system.debug('request:'+req.getBody());
    HttpResponse res = h.send(req);
    return res.getBody();
  }
}

 

I have given this class to public access and called this class in site's home page as controller.

 

 

Please Help me in this issue.

In a controller class i want to write a method to allow users to upload attachment.

Any suggestion.. what to have in the method?

Hi All,

 

My requirement is I have to develope Quiz Appln like SFDC Certificationexams  while clicking launch Btn then exam will start then time & seconds is displayed in each qns.Same functionality  I have to display in my Quiz Appln while user clicking Start btn time & seconds(01:30:00) should display in top of the page.In salesforce we dont have datatype like Time & Seconds ?How to write page and class?How to work this scenario pls help me ...Give example Urgent help needed

Thanks,

 

Vicky