• Prady01
  • SMARTIE
  • 982 Points
  • Member since 2010

  • Chatter
    Feed
  • 18
    Best Answers
  • 13
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 137
    Replies
The JSON format is like this
{

"GenerationTime": "20200119170533",
"ResponseCode": "MSK",
"ValidationExceptions": [
    {
        "SettlementDate": "20200113",
        "MSL": "_A",
        "MSN": {
                "ImportMSID": 1000000000059,
                "ExportMSID": null
               },
        "MRA": {
                        "SettlementPeriod": 34,
                        "DeliveredVolume": 23.21,
                        "ExceptionReason": "The import volume doesnot match with the actual allocation"
                    }
    },
    {
        "SettlementDate": "20200114",
        "MSL": "_B",
        "MSN": {
                "ImportMSID": 1000000000060,
                "ExportMSID": null
               },
        "MRA": {
                        "SettlementPeriod": 45,
                        "DeliveredVolume": 21.21,
                        "ExceptionReason": "The import volume doesnot match with the actual allocation"
                    }
    }
]
}

i wrote the wrapper class for it as
public class ExcFileWrapper{
    Public String GenerationTime; 
    Public String ResponseCode;
    Public List <ValidationExcepWrapper> ValidationExceptions; 

    public class ValidationExcepWrapper{ 
        Public String SettlementDate; //20200113"
        Public String MSL; //_A"
        public MSNWrapper MSN;
        Public MRAWrapper MRA;
    }
    public class MSNWrapper {
        Public String ImportMSID;
        Public String ExportMSID;
    }
    Public class MRAWrapper{
        Public integer SettlementPeriod;
        Public decimal DeliveredVolume;
        Public String ExceptionReason;
    }
}

After searching i found this is the correct way to write wrapper class for the JSON. But getting error as "Inner types are not allowed to have inner types". Where can i make change to eliminate this error?
Hi All,
My requirement is to open a custom lightning modal from the detail page and do the business logic. Like the following New Contact standard modal using button.
Example

Thanks in advance
Hello All,
I'm creating a visual force page that needs to contain information from every account in the application.

I tried using the Account standard controller, but I was unable to loop through all the accounts.

Is there a way to loop through (apex:repeat) all the accounts for a salesforce org?
i had gone through developer guide and other things, i need the a small example what really the metadata is with an example , of simple 
thanks and regards
My Visualforce Page Code is
<apex:page standardController="Campaign" recordSetVar="contacts" extensions="Campaign1">
    
    <apex:form >
    <apex:pageBlock title="Campaign Search">
            <h2>Name : </h2>
            <apex:inputText label="SearchName" value="{!searchName}"/>
            <apex:commandButton value="Search" action="{!searchbox}"> </apex:commandButton>
    </apex:pageBlock>
    
    <apex:pageBlock title="Campaign Detail">
        
    </apex:pageBlock>
    
        <apex:pageBlock title="Contacts List" id="contacts_list">
            <apex:pageBlockTable value="{! campaigns}" var="ct">
                <apex:column value="{! ct.Name }"/>
                <apex:column value="{! ct.Type }"/>
            </apex:pageBlockTable>
<table style="width: 100%"><tr>
    <td>
       Page: <apex:outputText value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>
    </td>            
    <td align="center">
<apex:commandLink action="{! Previous }" value="« Previous"
     rendered="{! HasPrevious }"/>
<apex:outputText style="color: #ccc;" value="« Previous"
     rendered="{! NOT(HasPrevious) }"/>
&nbsp;&nbsp;  
<apex:commandLink action="{! Next }" value="Next »"
     rendered="{! HasNext }"/>
<apex:outputText style="color: #ccc;" value="Next »"
     rendered="{! NOT(HasNext) }"/>
    </td>
    
    <td align="right">
        Records per page:
<apex:selectList value="{! PageSize }" size="1" >
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="20" itemLabel="20"/>
    <apex:actionSupport event="onchange" reRender="contacts_list"/>
</apex:selectList>
    </td>
</tr></table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

and My Custom Controller Code is
 
public class Campaign1 {

    public Campaign1(ApexPages.StandardSetController controller) {

    }


 public string searchName {get;set;}
 public list < Campaign> campaigns{get;set;}
 public Campaign c {get;set;}
   
   
   
   
 public Campaign1(apexPages.standardController con) {
 c = (Campaign)con.getRecord();
  campaigns= new list <Campaign> ();
  campaigns= [select ID, Name, StartDate, EndDate, Type from Campaign];
 }
 
 
 
 
 
 
 public void searchbox() {
  campaigns= new list <Campaign> ();
  String name = '%' + searchName + '%';
  campaigns= [select ID, Name, StartDate, EndDate, Type from Campaign where Name Like :name];
 }
 
 
 
}

I want make the search campaign page in 2 functions
First, Result was pagination
Second, Searched result about keyword.


How to development pagination in custom controller?
Maybe I write Pagination Code on custon controller? but I don't know make it..

Can you help me?
for(Contracting_Status__c cs : trigger.New)
    {
        if(trigger.isInsert)
        contractingid.add(cs.id);
        if(cs.Account__c != null && (cs.Contracting_Status__c != null))
        contrct_Accntid.add(cs.Account__c);
        if(cs.Carrier__c != null && (cs.Contracting_Status__c != null))
        Carrier_id.add(cs.Carrier__c);
        if(cs.Agency__c != null && (cs.Contracting_Status__c != null))
        Contrct_Agencyid.add(cs.Agency__c);
        if(trigger.isUpdate && cs.Agreement_release_date__c <= system.today())
        Contract_Id.add(cs.id);
        system.debug(cs.Carrier__c+'****PRINT CARRIER NAME****');
        if(cs.Product_Type__c != null && cs.Carrier__c == '00180000010mfZlAAI')
        ProductCode = cs.Product_Type__c;    
    }

Thank you.
Hi
anyone can help me to verify if my "and" function goes well, because doesnt work my code.
tks in advance

<apex:page standardController="QA_Order_Control__c" rendered="{(!QA_Order_Control__c.Line_Item_Brands_Opp_B__c== 'EMC')&&(!QA_Order_Control__c.OPS360_Status__c=='01.SentToOpps') }">


 <script type="text/javascript">
  { window.alert("Ponte Chingon"); }
 </script>
</apex:page>
Hi Developers any basic code to hide the rows in a table based on the user action, I am aware of the controller, I am fnding it diffcult to achieve in the JS, I have been searching the forum all day long!

Thanks
Shane
Hello,

I have a pageBlockTable on visualForce like below.
 
<apex:pageblock id="PB2">
                    <apex:pageblocktable value="{!pList}" var="item">
                        <apex:column headervalue="User with Skill">
                            {!item.User.FirstName}&nbsp;{!item.User.LastName}
                        </apex:column>
                        <apex:column headervalue="Skill Name">
                            {!item.ProfileSkill.Name}
                        </apex:column>                     
                    </apex:pageblocktable>
                </apex:pageblock>

User-added image
 

I will have many Users.  I am ordering it as per user name. I want to just display the first name and hid the repeated names.

Is there way to achieve my use case using CSS or javascript.

Thank you

  • April 30, 2015
  • Like
  • 0

HI Board,

 

   could any one help from a situation . The Situation is I do have two Check boxes (Checkbox A & Checkbox B).And My condition is to allow any one of the check box is true ,not the two at a time.

 

If checkbox A is true , Check box B should be False  and IF Checkbox B is true , Check box  B should be False , Both should not be TRUE.

 

 

 

Thanks In ADVANCE

Tarun(Dark Knight)

 

Hi, I was wondering if any of you have some kind of code sample that writes out data from a query like this:

 

My_Object.Field_A

My_Object.Field_B

My_Object.Field_C

My_Object.Field_A

My_Object.Field_B

My_Object.Field_C

 

And then I can just add dividers between each record that is written out this way. I basically want to simulate a basic report or word-style document, rather than using the usual pageBlockTable element.

  • December 19, 2012
  • Like
  • 0

i have appointment and accounts objects, both got 2 similar fields email and tax, if appoinment getting insert with the same email and tax of account record, then update appointment acc__c with account id.

 

 

how to implement in batch apex.

is my code written is correct?

 


global class updaterecords implements Schedulable
{

public updaterecords()
{

}
/* to excute the fields */
/*
global void execute(SchedulableContext ctx)
{
appointment []app=[select email,tax  from appointment where CreatedDate = TODAY ];

account []accts=[select email, tax_acc from account];


for(appointment s:app)
{
for(account a:accts)
{
if(a.email==s.email|| a.tax_acc==s.tax)
{
s.acct__c= a.ID;

}
}
}
update app;

}
}

 

 

 

  • December 15, 2012
  • Like
  • 0

Good evening sir,

can you please tell me how can i add custom controller to my standard controller

Hi,

 

Is it possible to deploy our apex class code with out writing test class or test method.

 

Thanks,

bujji

  • May 21, 2012
  • Like
  • 0

I have made a lookup field of contacts in ma asset object.

I have made a default contact as No user in ma contacts as contact is a compulsory field in assets.

whenever i add a contact and the value is not 'No User' the status of asset should change to 'assigned' from the picklist.

when i free dat asset from that contact or make it as No User the status the status should change from assigned  to instock.

Can Someone Please help me.

 

 

trigger updateAsset on Asset (after insert, after update) {
if(trigger.new[0].Name !=null && trigger.new[0].contactid != 'No User'){
Asset assetsOwned= [select Name,status from asset where Name=:trigger.new[0].Name];
assetsOwned.status = 'Assigned';
update assetsOwned;
}
/*if( trigger.isUpdate && trigger.old[0].id !=null && trigger.old[0].id != trigger.new[0].id){
Asset assetsOwnedOld = [select id, status from asset where id=:trigger.old[0].id];
assetsOwnedOld.status = 'Instock';
update assetsOwnedOld;


}*/
}

Hi forum, I am writting an application purely out of javascript and html. I would like to login into salesforce using username and password or also using the security token, It wouldnt matter. Do i have use anything other than pure html and js, Like node or something?

Imagine you have an html page opened in your browser which has two text boxes to enter username and password, using that how can i authenticate and login so that i can use tooling api to get the data from salesforce.

Please let me know or if anyone has a sample code to login into salesforce just using javascript, It would helpful if you share!

Thank you
PSM
Hi Forum.

     I am working on some development and I am facing few hicups with creating an algorithm for it. Please let me know if anyone has done this.

I have a list of object and this list contains object with duplicate values, I would like to eliminate the duplicates based on the Created date. Example imagine in the list I have two entity like this
Record1==> {obj.Name: Kat, Created Date: 6th july 2015}
Record2==>{obj.Name: Kat, Created Date: 7th july 2015}.
I would like to eliminate Record1 and keep Record2.

Many thanks
Prady01
 
Hello All, I was just wondering if I could get a sample code of using nested list i.e. example
List<List<Set<Integer>>> my_list_2 = new List<List<Set<Integer>>>();
Just wondering what will be usage of the nested lists (Any pros and cons) and how to add entities to nested list and get it back.

Thanks
Prady
Hi All, I would really appreciate any help on this, I am building a knowledge and answers site and I am using the chatter answers tag, I would like to display an error message to the user when the specified word is used while posting a question or replying to a question, The word can for example “Darn”

I did try adding the apex page message and this didn’t work, Does anyone has encountered this and found a workaround please let me know,

Thanks in advance.

Hi Developer forum, I am facing some issues with respect to click to dial functionality on a custom VF page, I did try and use 

<script src="/support/api/29.0/interaction.js" type="text/javascript"></script>

and

This is a column: <support:clickToDial number="{!r.Phone_Number__c}" entityId="{!r.id}"/>

but when I run the page it says click to dial disabled. when I hover over the phone icon on the VF page, Not sure what I am missing out here, Any pointers would be greatly appreciated. This is a inline VF page on another object standard detail page.

Thanks
Prady

Hi Developer Forums, Need a few pointer

         My problem: I have two VF pages VF1 and VF2, The VF1 page is an inline page on a standard object detail page(Its need less to say that there is an object relation b/w standard object) and then this VF1 page has a Create new record button which navigate to VF2, On this VF2 I have have a look up field I would like to pre-populate since the action was made form the standard object detail page. This VF2 is a pop up page, Since  this is a pop up, I will have to do it in JS and then I used the Name and ID of the field passed in url, then used Jquery on the VF2 page to place the value on page load using the below.

$j('.lookupInput').html('{!clientName}')

I have passed the Varibale form class to JS==> ClientName

Any pointers would be much appreciated thanks
Prady

Hi there, I have an approval process and in this approval process I have added an email template with merge fields (ApprovalRequest.Comments) for comments and this template I have used in the final rejection action as an email alert but when I receive the email, I get this field value as blank even though the user has entered the comment, I did also search and found that

 

ApprovalsIf the email template you choose contains approval merge fields named{!ApprovalRequest.field_name}, these fields will return values only when that email template is used as the approval assignment template. If you use the template for any other email alert action—in either workflow rules or approval processes—the merge fields will return a null value.

 

Any help/comments on this is greatly appreciated

 

Thanks

Pradeep

  • September 03, 2013
  • Like
  • 1

Hello there people i have a simple class for which i am working on a test class and cant seem to figure out to pass the record id... The whole function is i have page with two page blocksections and then pass the boolean value from class to page so that for certain record type only releted page blocksection should be visible... Here is the piece of class and i have marked the lines that was not covered by test

public class cont{

 public boolean boolval{get;set;}
 
    public cont(ApexPages.StandardController controller) {
        customobject pr = (customobject)controller.getRecord();
    
 
		if(ApexPages.currentPage().getParameters().get('id')!=null)
		{
			customobject  pr1 = [select id, RecordTypeId from customobject where id =  :ApexPages.currentPage().getParameters().get('id')];  
			if  (pr1.RecordTypeId == 'ID of the record type/or label')
			{
				boolval=true;
				          
			} 
			else 
			{
			boolval=false; // not covered in test
			}
        }
		
	    else if(ApexPages.currentPage().getParameters().get('RecordType')== 'ID of the record type/or label')
        boolval=true; // not covered in test
        else 
		boolval=false;
	}
 
}
@isTest
private class contTest {


        static testMethod void testcont()
        {        
            
         customobject pr = new customobject();
         insert pr;
          PageReference pageRef = Page.custompage;
          pageRef .getParameters().put('id',pr.id);
         
           Test.setCurrentPageReference(pageRef);
           ApexPages.StandardController controller = new ApexPages.StandardController(pr); 
           PerformanceReviewController cont = new PerformanceReviewController(controller);  
         
       
           
            customobject pr1 = new customobject();
          
           PageReference pageRef1 = Page.custompage;
          pageRef1 .getParameters().put('RecordTypeid','0124000000015Sq');
       
          Test.setCurrentPageReference(pageRef1);
           ApexPages.StandardController controller1 = new ApexPages.StandardController(pr1); 
           PerformanceReviewController cont1 = new PerformanceReviewController(controller1);  
           
           
         }     
         
    } 

 

as " not covered ".... Thanks in advance if ayone would help me out... Any help would be deeply

Appreciated :smileyhappy :)

Hello People, Thanks in advance for any help i could get... I am writing a test class for a trigger on content object and when i insert a new record on content version and then try to set the custom field on that object but i get an error saying FIELD_INTEGRITY_EXCEPTION, You cannot set custom fields or tags on a document published into a personal library. Fields set: Opportunity: [], plz any help would be greatly appreciated, thanks...

 

 

@istest

private class ProjectName_test {
    
    static testMethod void testProjectName(){
    
             Employee__c e1 = new Employee__c(First_Name__c = 'test11', Last_Name__c = 'test11', Start_Date__c = Date.valueOf('2009-10-05'));
            insert e1;
    
    
        Profile p = [select id from profile where name='System Administrator'];
        User u = new User(alias = 'standt', email='standarduser1@testorg.com',
                        emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                        localesidkey='en_US', profileid = p.Id,SFDC_EmployeeId__c = e1.id,
                        timezonesidkey='America/Los_Angeles', username='standarduser1@testorg.com');
    
    
        account a = new account();
        a.name='Test name';
        insert a;
        
      Project__c dp = new Project__c();
        insert dp;
        
        Opportunity op = new Opportunity();
         op.Accountid = a.id;
         op.Name = 'Swarm Test Opp';
         op.StageName = 'Different Stage';
         op.CloseDate = Date.newInstance(2010, 03, 26);
         op.Amount = 555;
         op.Project__c = dp.id;
         insert op;
        
        
           
        ContentVersion cv = new ContentVersion();
          
       
        
        
        //cv.FirstPublishLocationId='068Q00000006bsz';
        cv.title='Test title';
       
        cv.VersionData=blob.valueof('New Bitmap Image.bmp');
         cv.Account__c = a.id;
     
        cv.Opportunity__c=op.id;
       // cv.RecordtypeId='012400000009Bj8AAE';
     // cv.RecordtypeId='058400000004CY3';//sales documents record type id
     //  cv.RecordtypeId ='00h40000000zGVa';
        insert cv;
       
        ContentVersion cov = [select id,Project__c,Opportunity__c,RecordTypeId from ContentVersion where id=:cv.id];
        cov.Opportunity__c = op.id;
        
     
       update cov;
        system.assertequals(cov.DreamTeam_Project__c,op.DreamTeam_Project__c);
       
        
        }
        
 }

 

  • September 19, 2011
  • Like
  • 0

Hello Everybody.... Thanks to anyone who can lend me some insights on my problem..

 

        First of all i am writting a simple trigger on content object to update a custom lookup field, but not seem able to query the fields on content object, when i generated the API in the org i could see that all the custom fields are under the object name ContentVersion....

 

         Wat i am trying to do is, there a an opportunity lookup field on content object and then there is another field called project lookup field on content object, I want to populate this project field by getting the data from related opportunity(from which i want to pull the data to populate project field on content object)..  here is my code.. Any suggestions wil be very helpful thanks..

 

 

 

trigger ProjectName on ContentVersion(after insert)
{
    
    set<id> oppid = new set<id>();
    set<id> contid = new set<id>();
 //   set<id> conwsid =new set<id>();
    List<ContentVersion> content = new List<ContentVersion>();
    content=[select ContentDocumentId,Opportunity__c from ContentVersion where Id in:Trigger.new];
    // List<ContentWorkspaceDoc> cow = new List<ContentWorkspaceDoc>();
   //cow=[select ContentWorkspaceId from ContentWorkspaceDoc where ContentDocumentId in:contid ];
    
    for(ContentVersion c:content)
    {
   
    contid.add(c.ContentDocumentId);
    oppid.add(c.Opportunity__c);
    }
  /*  for(ContentWorkspaceDoc cw:cow)
    {
    conwsid.add(cw.ContentWorkspaceId);
    }*/
    
    
    List<ContentVersion> updatecontent = new List<ContentVersion>();
    List<Opportunity> opp = new List<Opportunity>();
    opp = [select id, DreamTeam_Project__c from opportunity where id in: oppid ];
    List<ContentVersion> cont = new List<ContentVersion>();
    cont=[select id,DreamTeam_Project__c from ContentVersion where id in:contid and opportunity__c in:oppid and Id in:contid];//and RecordTypeId=:'00h400000013I6S'];
    for(Opportunity op:opp){
    for(ContentVersion cv:cont){
    cv.DreamTeam_Project__c = op.DreamTeam_Project__c;
   
    updatecontent.add(cv);
    }
   update updatecontent;
    }
   
    }
    
    

 

  • September 07, 2011
  • Like
  • 1

Hello Hi, there.... Today was working on VF page and the requirement was like this.. First of all i have a VF page which will display the data and the fields from on object.. Example assume there are two fields in the object, and lets assume these fields are Name, Age...Now if i run the VF page it will display name and age fields and the data stored in that object... But what i want to do is--- I want to display the new field called Address on a VF page as soon as i go and add this(address) field in the object through set up menu.. Is this possible!!!... I will be glad with any help and i would thank them advance for it:)

I have page, Which inturn contains picklists like category when I select one category then the data related to that catogory must be displayed in the table.. Which is all working fine (page/class)but I am getting an error saying ,Too many query rows: 10001.. So can anyone, help me work around this problem...  

Hi Forum.

     I am working on some development and I am facing few hicups with creating an algorithm for it. Please let me know if anyone has done this.

I have a list of object and this list contains object with duplicate values, I would like to eliminate the duplicates based on the Created date. Example imagine in the list I have two entity like this
Record1==> {obj.Name: Kat, Created Date: 6th july 2015}
Record2==>{obj.Name: Kat, Created Date: 7th july 2015}.
I would like to eliminate Record1 and keep Record2.

Many thanks
Prady01
 
Hello All, I was just wondering if I could get a sample code of using nested list i.e. example
List<List<Set<Integer>>> my_list_2 = new List<List<Set<Integer>>>();
Just wondering what will be usage of the nested lists (Any pros and cons) and how to add entities to nested list and get it back.

Thanks
Prady
Hi All, I would really appreciate any help on this, I am building a knowledge and answers site and I am using the chatter answers tag, I would like to display an error message to the user when the specified word is used while posting a question or replying to a question, The word can for example “Darn”

I did try adding the apex page message and this didn’t work, Does anyone has encountered this and found a workaround please let me know,

Thanks in advance.

Hi Developer forum, I am facing some issues with respect to click to dial functionality on a custom VF page, I did try and use 

<script src="/support/api/29.0/interaction.js" type="text/javascript"></script>

and

This is a column: <support:clickToDial number="{!r.Phone_Number__c}" entityId="{!r.id}"/>

but when I run the page it says click to dial disabled. when I hover over the phone icon on the VF page, Not sure what I am missing out here, Any pointers would be greatly appreciated. This is a inline VF page on another object standard detail page.

Thanks
Prady

Hi there, I have an approval process and in this approval process I have added an email template with merge fields (ApprovalRequest.Comments) for comments and this template I have used in the final rejection action as an email alert but when I receive the email, I get this field value as blank even though the user has entered the comment, I did also search and found that

 

ApprovalsIf the email template you choose contains approval merge fields named{!ApprovalRequest.field_name}, these fields will return values only when that email template is used as the approval assignment template. If you use the template for any other email alert action—in either workflow rules or approval processes—the merge fields will return a null value.

 

Any help/comments on this is greatly appreciated

 

Thanks

Pradeep

  • September 03, 2013
  • Like
  • 1

Hello there people i have a simple class for which i am working on a test class and cant seem to figure out to pass the record id... The whole function is i have page with two page blocksections and then pass the boolean value from class to page so that for certain record type only releted page blocksection should be visible... Here is the piece of class and i have marked the lines that was not covered by test

public class cont{

 public boolean boolval{get;set;}
 
    public cont(ApexPages.StandardController controller) {
        customobject pr = (customobject)controller.getRecord();
    
 
		if(ApexPages.currentPage().getParameters().get('id')!=null)
		{
			customobject  pr1 = [select id, RecordTypeId from customobject where id =  :ApexPages.currentPage().getParameters().get('id')];  
			if  (pr1.RecordTypeId == 'ID of the record type/or label')
			{
				boolval=true;
				          
			} 
			else 
			{
			boolval=false; // not covered in test
			}
        }
		
	    else if(ApexPages.currentPage().getParameters().get('RecordType')== 'ID of the record type/or label')
        boolval=true; // not covered in test
        else 
		boolval=false;
	}
 
}
@isTest
private class contTest {


        static testMethod void testcont()
        {        
            
         customobject pr = new customobject();
         insert pr;
          PageReference pageRef = Page.custompage;
          pageRef .getParameters().put('id',pr.id);
         
           Test.setCurrentPageReference(pageRef);
           ApexPages.StandardController controller = new ApexPages.StandardController(pr); 
           PerformanceReviewController cont = new PerformanceReviewController(controller);  
         
       
           
            customobject pr1 = new customobject();
          
           PageReference pageRef1 = Page.custompage;
          pageRef1 .getParameters().put('RecordTypeid','0124000000015Sq');
       
          Test.setCurrentPageReference(pageRef1);
           ApexPages.StandardController controller1 = new ApexPages.StandardController(pr1); 
           PerformanceReviewController cont1 = new PerformanceReviewController(controller1);  
           
           
         }     
         
    } 

 

as " not covered ".... Thanks in advance if ayone would help me out... Any help would be deeply

Appreciated :smileyhappy :)

Hello Everybody.... Thanks to anyone who can lend me some insights on my problem..

 

        First of all i am writting a simple trigger on content object to update a custom lookup field, but not seem able to query the fields on content object, when i generated the API in the org i could see that all the custom fields are under the object name ContentVersion....

 

         Wat i am trying to do is, there a an opportunity lookup field on content object and then there is another field called project lookup field on content object, I want to populate this project field by getting the data from related opportunity(from which i want to pull the data to populate project field on content object)..  here is my code.. Any suggestions wil be very helpful thanks..

 

 

 

trigger ProjectName on ContentVersion(after insert)
{
    
    set<id> oppid = new set<id>();
    set<id> contid = new set<id>();
 //   set<id> conwsid =new set<id>();
    List<ContentVersion> content = new List<ContentVersion>();
    content=[select ContentDocumentId,Opportunity__c from ContentVersion where Id in:Trigger.new];
    // List<ContentWorkspaceDoc> cow = new List<ContentWorkspaceDoc>();
   //cow=[select ContentWorkspaceId from ContentWorkspaceDoc where ContentDocumentId in:contid ];
    
    for(ContentVersion c:content)
    {
   
    contid.add(c.ContentDocumentId);
    oppid.add(c.Opportunity__c);
    }
  /*  for(ContentWorkspaceDoc cw:cow)
    {
    conwsid.add(cw.ContentWorkspaceId);
    }*/
    
    
    List<ContentVersion> updatecontent = new List<ContentVersion>();
    List<Opportunity> opp = new List<Opportunity>();
    opp = [select id, DreamTeam_Project__c from opportunity where id in: oppid ];
    List<ContentVersion> cont = new List<ContentVersion>();
    cont=[select id,DreamTeam_Project__c from ContentVersion where id in:contid and opportunity__c in:oppid and Id in:contid];//and RecordTypeId=:'00h400000013I6S'];
    for(Opportunity op:opp){
    for(ContentVersion cv:cont){
    cv.DreamTeam_Project__c = op.DreamTeam_Project__c;
   
    updatecontent.add(cv);
    }
   update updatecontent;
    }
   
    }
    
    

 

  • September 07, 2011
  • Like
  • 1

Hello Hi, there.... Today was working on VF page and the requirement was like this.. First of all i have a VF page which will display the data and the fields from on object.. Example assume there are two fields in the object, and lets assume these fields are Name, Age...Now if i run the VF page it will display name and age fields and the data stored in that object... But what i want to do is--- I want to display the new field called Address on a VF page as soon as i go and add this(address) field in the object through set up menu.. Is this possible!!!... I will be glad with any help and i would thank them advance for it:)

I have page, Which inturn contains picklists like category when I select one category then the data related to that catogory must be displayed in the table.. Which is all working fine (page/class)but I am getting an error saying ,Too many query rows: 10001.. So can anyone, help me work around this problem...  

Hello folks,

I have a problem with displaying my visualforce page. What I have right now ist this:
User-added image
What I want is this:

User-added image

  • <apex:form style="width:100%"> is fine and should stay this way (displaying the checkboxes and the commandButtons)
  • <apex:map width="70%"> seems to be working as well (displaying the map)
  • <apex:pageBlockTable width="30%"> is what seems to be the problem (displaying a table)

User-added image
Here is my Page:

 

<apex:page standardcontroller="Account" extensions="FindNearbyController" docType="html-5.0" lightningStylesheets="true" action="{!findNearby}"> 

    <apex:pageBlock >
      <apex:pageBlockSection columns="1" id="geomap">
         

      <apex:outputText style="font-size:19px;" value="
       
      {!IF(myInput = 'ger' && fcb = true,
       
       '{0} Kunden aus den letzten {1} Tagen in der Branche {2} deutschlandweit gefunden.',    
      
       IF(myInput = 'state'  && fcb = false, 
       
       '{0} Kunden aus den letzten {1} Tagen in {5} gefunden.',
            
        IF(myInput = 'state' && fcb = true,
        
       '{0} Kunden aus den letzten {1} Tagen in der Branche {2} in {5} gefunden.', 
       
       IF(myInput != 'state' && myInput != 'ger' && fcb = true,
       
       '{0} Kunden im {3} km Umkreis aus den letzten {1} Tagen in der Branche {2} gefunden.',
       
       '{0} Kunden im {3} km Umkreis aus den letzten {1} Tagen gefunden.'
       
       ))))}">
       
       <apex:param value="{!warehouses.size}"/>
       <apex:param value="{!myTime}"/>
       <apex:param value="{!currentAccount.WZ_Abteilung__c}"/>
       <apex:param value="{!myInput}"/>
       <apex:param value="{!currentAccount.Name}"/>
       <apex:param value="{!currentAccount.ShippingState}"/>
       
       </apex:outputText> 

        <apex:form style="width:100%">
        
        
          <!-- FILTER 1 (Branche) --> 
        <apex:inputCheckBox id="filter1" disabled="{!currentAccount.WZ_Buchstabe__c = null || myinput = 'ger' }" value="{!fcb}" >
        <apex:actionSupport event="onclick" action="{!findNearby}" rerender="geomap"/>
        </apex:inputCheckBox>
        <apex:outputLabel for="filter1" value="nur aus verwandter Branche ({!currentAccount.WZ_Abteilung__c})" />
      
        <!-- FILTER 2 (Owner) -->     
        <apex:inputCheckBox id="filter2" value="{!fco}" >
        <apex:actionSupport event="onclick" action="{!findNearby}" rerender="geomap"/>
        </apex:inputCheckBox>
        <apex:outputLabel for="filter2" value="nur meine Kunden" />
  
    <!-- Textfeld zur Angabe von km -->
          <apex:inputText value="{!myinput}" style="width:60px" rendered="{!myinput != 'ger' && myinput != 'state' }"/>
          <apex:commandButton value="Umkreis anpassen (in km)" rerender="geomap" action="{!findNearby}" rendered="{!myinput != 'ger' && myinput != 'state' }"/>
                  
         <!-- Button zurück -->  
        <apex:commandButton action="{!findNearby}" value="Zurück zur lokalen Suche" reRender="geomap" rendered="{!myinput = 'ger' || myinput = 'state' }">
         <apex:param assignTo="{!myInput}" name="back" id="back" value="{!currentAccount.MetaData_Distance_Customer__c}"/>
        </apex:commandButton>
                
              <!-- Button deutschlandweit --> 
        <apex:commandButton action="{!findNearby}" value="Deutschlandweit" reRender="geomap" rendered="{!myinput != 'ger'}" disabled="{!IF(fcb = false && fco = true,false,IF(fcb = true && fco = true,false,IF(fcb = true && fco = false,false,true)))}">
         <apex:param assignTo="{!myInput}" name="ger" id="ger" value="ger"/>
        </apex:commandButton>
        
        <!-- Button Bundesland-->  
        <apex:commandButton action="{!findNearby}" value="nur in {!currentAccount.ShippingState}" reRender="geomap" rendered="{!myinput != 'state'}">
         <apex:param assignTo="{!myInput}" name="state" id="state" value="state"/>
        </apex:commandButton>
  
     <!-- Textfeld zur Angabe von Zeitraum -->     
          <apex:inputText value="{!myTime}" style="width:60px"/>
          <apex:commandButton value="Zeitraum anpassen (in Tagen)" rerender="geomap" action="{!findNearby}"/>
      
 
    
        </apex:form> 

            <apex:map width="70%" height="300px" mapType="roadmap" center="{!currentAccount.ShippingStreet},{!currentAccount.ShippingState},{!currentAccount.ShippingCity},{!currentAccount.ShippingPostalCode}" showOnlyActiveInfoWindow="false" >
            
          
             <!-- Add a CUSTOM map marker for the current account -->
             <apex:mapMarker title="{! currentAccount.Name }" position="{!currentAccount.ShippingStreet},{!currentAccount.ShippingState},{!currentAccount.ShippingCity},{!currentAccount.ShippingPostalCode}" icon="{!URLFOR($Resource.location)}"/> 
            
            <!-- Add a CUSTOM map marker for the account list -->

                <apex:repeat value="{!warehouses}" var="war">
                    <apex:mapMarker position="{!war.GeoLocPosition__c}" title="{!war.Name}" 
                    icon="{!IF(war.AE_letzte_12_Monate__c > 5000,URLFOR($Resource.ms_star),
                            IF(war.AD_MS_Rel_Anzahl_bez__c <= currentAccount.AD_MS_Rel_Anzahl_bez__c && war.WirtschaftszweigWZ08__c = currentAccount.WirtschaftszweigWZ08__c && war.Mitarbeiternzahl_final__c = currentAccount.Mitarbeiternzahl_final__c,URLFOR($Resource.perfect_fit),
                            IF(war.Accountinhaber_Text__c= 'JOB SHOP',URLFOR($Resource.shop),
                    
                    URLFOR($Resource.ms_marker))))}" >
            

            <!-- Add Info markers -->
                    
                    <apex:mapInfoWindow >
                                                         
                    <!-- Name + Link -->
                     <apex:outputPanel layout="block" style="font-weight: bold;">
                     <apex:outputLink value="{! '/' + war.Id}">
                    <apex:outputText >{! war.Name }</apex:outputText>
                    </apex:outputLink>
                    </apex:outputPanel>
                                      
                    <!-- Straße -->
                    <apex:outputPanel layout="block">
                    <apex:outputText >{! war.ShippingStreet }</apex:outputText>
                    </apex:outputPanel>
                    
                    <!-- Owner -->
                    <apex:outputPanel layout="block">
                    <apex:outputText >{! war.Accountinhaber_Text__c }</apex:outputText>
                    </apex:outputPanel>
                    
                    <!-- Vertriebskanal -->
                    <apex:outputPanel layout="block">
                    <apex:outputText >{! war.Auftragseingangstyp__c}</apex:outputText>
                    </apex:outputPanel>
                    
                    <!-- Index -->
                     <apex:outputPanel layout="block">
                   <apex:outputLink value="{!war.indexurl__c}">
                    <apex:outputText >{!war.anzeigendaten_de_ID_account__c}</apex:outputText>
                    </apex:outputLink>
                    </apex:outputPanel>
                                        
                    <!-- Branche -->
                     <apex:outputPanel layout="block">
                    <apex:outputText >{! war.WirtschaftszweigWZ08__c}</apex:outputText>
                    </apex:outputPanel>
                    
                    <!-- Link zum Customer Cockpit -->
                    <apex:outputPanel layout="block">
                   <apex:outputLink value="{!war.URL_zum_CC__c}">
                    <apex:outputText >zum Customer Cockpit</apex:outputText>
                    </apex:outputLink>
                    </apex:outputPanel>
                                                         
                    </apex:mapInfoWindow>

                    </apex:mapMarker>
                </apex:repeat>
            </apex:map>

    <!-- TABLE -->
        <apex:pageBlockTable width="30%" value="{!warehouses}"  var="war" >
              
         <apex:column > <input type="checkbox" />
         <apex:facet name="header">Kunde</apex:facet><apex:outputLink value="/{!war.Id}" target="_blank">{!war.Name}</apex:outputLink>
         </apex:column>
         
   <!--      <apex:column ><apex:facet name="header">Straße</apex:facet>{!war.ShippingStreet}</apex:column> -->
   <!--      <apex:column ><apex:facet name="header">Stadt</apex:facet>{!war.ShippingCity}</apex:column> -->
   <!--      <apex:column ><apex:facet name="header">Inhaber</apex:facet>{!war.Accountinhaber_Text__c }</apex:column> -->
   <!--      <apex:column ><apex:facet name="header">Index</apex:facet><apex:outputLink value="{!war.indexurl__c}" target="_blank">{!war.anzeigendaten_de_ID_account__c}</apex:outputLink></apex:column> -->
   <!--      <apex:column ><apex:facet name="header">Customer Cockpit</apex:facet><apex:outputLink value="{!war.URL_zum_CC__c}" target="_blank">zum Customer Cockpit</apex:outputLink></apex:column> -->

      </apex:pageBlockTable>

        </apex:pageBlockSection>

    </apex:pageBlock>
    
    
</apex:page>

When I switch from <apex:pageBlockSection columns="1"> to <apex:pageBlockSection columns="2"> it gets all messed up:

User-added image

What do I have to do?

Hi to everybody,
I need to aggregate some information from a Parent to Child Relationship Query.

For example, with the following basic query:
SELECT Account.Name,(SELECT Contact.Name FROM contacts) FROM Account

I'd like to count the number of contacts for a specific account.
Is that possible?

Thank you!


 
Hello All, 

    Running into problems whilst deleting a custom object. Please help! Attaching the error screenshot ...

User-added image
Regards
Rey
 
Hi,

I am running in to an issue that I was hoping someone might have some insight in to. I have a method in a class triggered by contact insert or update. This method will check to see if a contact has a box checked and if it does, it will create a correspondinng user record with the ContactId set to the Id of the contact that was being created/edited. 

The issue that I am having is with the test code coverage. I am getting the error "UNKNOWN_EXCEPTION, portal account owner must have a role". Now I have seen the workaround for this by creating a user with a role and then putting the community user creation code inside System.runAs context with the user you created. This works for community users created in the test class itself, however, if the test class is not actually creating the community user directly, but rather by creating a contact which triggers the class mentioned above to create a community user, it fails with the same role error mentioned above. 

In all my searching, all I have found is a solution to the first issue where the community user is being created in the test class itself. I have not found any info for resolving it if the test class it then calling out to another class that creates the user. Any info on how I might be able to resolve would be greatly appreciated.

Thanks,

Chris
 
  • April 13, 2020
  • Like
  • 0
The JSON format is like this
{

"GenerationTime": "20200119170533",
"ResponseCode": "MSK",
"ValidationExceptions": [
    {
        "SettlementDate": "20200113",
        "MSL": "_A",
        "MSN": {
                "ImportMSID": 1000000000059,
                "ExportMSID": null
               },
        "MRA": {
                        "SettlementPeriod": 34,
                        "DeliveredVolume": 23.21,
                        "ExceptionReason": "The import volume doesnot match with the actual allocation"
                    }
    },
    {
        "SettlementDate": "20200114",
        "MSL": "_B",
        "MSN": {
                "ImportMSID": 1000000000060,
                "ExportMSID": null
               },
        "MRA": {
                        "SettlementPeriod": 45,
                        "DeliveredVolume": 21.21,
                        "ExceptionReason": "The import volume doesnot match with the actual allocation"
                    }
    }
]
}

i wrote the wrapper class for it as
public class ExcFileWrapper{
    Public String GenerationTime; 
    Public String ResponseCode;
    Public List <ValidationExcepWrapper> ValidationExceptions; 

    public class ValidationExcepWrapper{ 
        Public String SettlementDate; //20200113"
        Public String MSL; //_A"
        public MSNWrapper MSN;
        Public MRAWrapper MRA;
    }
    public class MSNWrapper {
        Public String ImportMSID;
        Public String ExportMSID;
    }
    Public class MRAWrapper{
        Public integer SettlementPeriod;
        Public decimal DeliveredVolume;
        Public String ExceptionReason;
    }
}

After searching i found this is the correct way to write wrapper class for the JSON. But getting error as "Inner types are not allowed to have inner types". Where can i make change to eliminate this error?
public class StockListController {
    
public List<Stock_Item__c> getStockItems() {
    
    List<Stock_Item__c> results = Database.query(
        'SELECT ID, Item_Name__c, Item_Stock_is_Low__c, Minimum_Stock_Level__c, Stock_on_Hand__c ' +
        'FROM Stock_Item__c ' +
        'WHERE Item_Stock_is_Low__c = true'
    );
    return results;
}
}    



<apex:page lightningStyleSheets="true" Controller="StockListController">
    <apex:form>
        <apex:pageBlock title="Low Stock Items" id="stock_item_list">
            
            <!-- Stock Item List goes here -->
            <apex:pageBlockTable value="{! StockItems }" var="si">
                <apex:column value="{! si.ID }"/>
                <apex:column value="{! si.Item_Name__c }"/>
                <apex:column value="{! si.Item_Stock_is_Low__c }"/>
                <apex:column value="{! si.Minimum_Stock_Level__c }"/>
                <apex:column value="{! si.Stock_on_Hand__c }"/>
    
</apex:pageBlockTable>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image
How to display multiple line toast messages? 
Hii Friends,
Please help me.
The below javascript code on custom detail page button  shows error on click it.
--------------------------------------------------------------------------------------
{!REQUIRESCRIPT("/soap/ajax/47.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/47.0/apex.js")} 

var tempID='{!Offers_Appraisals__c.Id}';
if({!Offers_Appraisals__c.Id}!=Null)
{
sforce.apex.execute("NanoHRSheet","HRSalarySheet",tempID);
}
--------------------------------------------------------------------------------------
Error:
User-added image

What's wrong with code?
Please help me.
Thank you
  • April 10, 2020
  • Like
  • 0
Hi All,
My requirement is to open a custom lightning modal from the detail page and do the business logic. Like the following New Contact standard modal using button.
Example

Thanks in advance
Hi everybody,
I am stuck with how to modify security settings using triigers.
Please help me to write the following trigger.
Set the OWD on the opportunity as private and Remove modify all permission on a profile using trigger.
Hi, I am new to Apex. I have the below doubt,
trigger ClosedOpportunity on Opportunity (after update) {
    List<task> carry=New List<task>();
    for(opportunity opp:trigger.new){
    if(opp.stagename=='Closed won'){
     task t=new task(
         whatid=opp.id,
         status='Active',
         Subject='Follow Up Opp Task',
         ActivityDate=system.today()
     ) ; 
        carry.add(t);
    }
        }
    insert carry;
}
In the above, code. Its working when i am putting "Insert carry" But not working if i want to put "Insert t", As i can see both are instances created, so why do i have to create "carry" and add "t" in that. Why not i can "insert t" directly ?
 

Hello all,

I've been trying for awhile to create a list button that will allow the creation of multiple child records of the same parent record on one Visualforce page (rather than clicking save and new over and over). I need to pass the parent ID and assign a record type, and I'd prefer that happen without the user having to do anything other than click the button on the related list. My visualforce page works in that if I preview it, I can see each field in a column, and the "add" link is working to add new rows. However, the parent ID isn't getting passed, I can't figure out how to assign the record type ID, and the "x" link to delete a row isn't working.

I've posted on the forum about this multiple times, but have not received many replies.

This would be a huge help for the organizations I work with, and I'd be willing to pay for a few hours of someone's time to help me get the code right. Any one interested in helping me out?

  • February 04, 2020
  • Like
  • 0
global class UpdateTheValue implements Database.Batchable<Employee_Detail__c>
{
   global final String Query;
   global integer Available_Leave__c;
global SummarizeAccountTotal(String q)
{
       Query=q;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }
   
   global void execute(Database.BatchableContext BC,List<Employee_Detail__c> scope){
      for(Employee_Detail__c s : scope)
      {
         Available_Leave__c= Integer.valueOf(s.get('Available_Leave__c'))+4;
      }
       update scope;
   }

global void finish(Database.BatchableContext BC){
   }
}

Error:class UpdateTheValue must be implement method:system.iterable Database.Batchable.start.(Database.batchablecontext)
How I can show 5000 Record On the Vf page without using pagination and attribute readonly?
Dear Team ,

Greetings !!!

I am performing REST API UsingWeather Example . M refering this website https://focusonforce.com/integration-and-data-loading/rest-api-using-weather-example/ . On my visual force m experiencing error . Plz have a look on my Code and snapshot .  I enable my API moreover configuration settings also i made . Plz help me to solve this issue .

User-added image
APEX Class :

public with sharing class testopenweather {

	public String city {get;set;}
	public String temp {get;set;}
	public String pressure {get;set;}
	public String humidity {get;set;}
	public String temp_min {get;set;}
	public String temp_max {get;set;}

	public testopenweather(ApexPages.StandardController stdController) {
		Account account = (Account)stdController.getRecord();
		account = [SELECT Id, ShippingCity FROM Account WHERE Id =:account.Id];
		//account = [SELECT Id, ShippingCity FROM Account WHERE Id ='0012v00002pNKoyAAG'];
        
		String accountCity = account.ShippingCity;
		String apiKey = '0284633ceb975c6164fa90f016d87e02';

		String requestEndpoint = 'http://api.openweather.org/data/2.5/weather';
		requestEndpoint += '?q=' + accountCity;
		requestEndpoint += '&units=metric';
		requestEndpoint += '&APPID=' + apiKey;
		
		Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setEndpoint(requestEndpoint);
		request.setMethod('GET');
		HttpResponse response = http.send(request);

		// If the request is successful, parse the JSON response.
		if (response.getStatusCode() == 200) {

		   // Deserialize the JSON string into collections of primitive data types.
		  Map<string,object> results=( Map<string,object>)JSON.deserializeUntyped(response.getBody());
           // city=string.valueof(result.get('name'));
           city = String.valueOf(results.get('name')); 
             Map<string,object> mainresults=( Map<string,object>)(results.get('main'));
            temp = string.valueOf(mainresults.get('temp'));
             pressure = string.valueOf(mainresults.get(' pressure'));
             humidity = string.valueOf(mainresults.get('humidity'));
             temp_min = string.valueOf(mainresults.get('temp_min'));
             temp_max = string.valueOf(mainresults.get('temp_max'));
            
        }
        else {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Tere was an error');
            ApexPages.addMessage(myMsg);
            
        }
    }
}

Visual Force :

<apex:page standardController="Account" extensions="testopenweather" showHeader="false" sidebar="false">
    <apex:pageBlock title="{!city} Weather">
		<apex:pageBlockSection>

			<apex:pageMessages/>

			<apex:outputText label="Temperature" value="{!temp}"/>
			<apex:outputText label="Pressure" value="{!pressure}"/>
			<apex:outputText label="Humidity" value="{!humidity}"/>
			<apex:outputText label="Minimum Temperature" value="{!temp_min}"/>
			<apex:outputText label="Maximum Temperature" value="{!temp_max}"/>

		</apex:pageBlockSection>
	</apex:pageBlock>
</apex:page>
Thanks & Regards
Sachin Bhalerao
 

I have a Webservice which sends me transactions. We want to track the changes record by record just as a Bank Statement. We are using webservice to store Credit and Debit amount.

In the trigger we are quering for the last record [I know this is not what best practice says, but was not able think of a better way] and then calculating the balance for this record.

trigger:

trigger ASM_Balance on Assembly_Transactions__c (before insert) {
    
    List<Assembly_Transactions__c> trans = [SELECT ID, balance__c FROM Assembly_Transactions__c WHERE Wallet_Owner__c =: Trigger.new[0].Wallet_Owner__c ORDER BY CreatedDate DESC LIMIT 1];
    
    Double balance = 0;
    if(trans.size()>0)
    {
        if(trans[0].balance__c != null)
            balance = trans[0].balance__c;
    }
    Assembly_Transactions__c tr = Trigger.new[0];
    Double cr = tr.credit__c;
    Double dt = tr.debit__c;
    Double amount = balance+cr-dt;
    tr.balance__c = amount;
}

The error occours when we have two transactions at the same time, and the webservice is hit back to back. 

I think this is due to SOQL being run just before we have the last transaction inserted successfully. 

Please help me out with suggestions.

When I open any opportunity from the outlook sidepanel, there is a Log button to the top extreme right, which actually opens a page to send an email.
Is there any way to remove that log button?
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var updateRecords = [];

if (records[0] == null) { //if the button was clicked but there was no record selected
alert("Please select at least one record to update."); //alert the user that they didn't make a selection
} else { //otherwise, there was a record selection
for (var a=0; a<records.length; a++) { //for all records
var update_Opportunity = new sforce.SObject("Opportunity"); //create a new sObject for storing updated record details
update_Opportunity.Id = records[a]; //set the Id of the selected Opportunity record
update_Opportunity.OwnerID= "0050V0000073CQuQAM"; //set the value for Status to 'Unqualified'
updateRecords.push(update_Opportunity); //add the updated record to our array
}
result = sforce.connection.update(updateRecords); //push the updated records back to Salesforce
parent.location.href = url; //refresh the page
}