• Newbie10
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 16
    Replies

My use case is to find total followers on a particular record

So when somebody follows/unfollows that record i would like to update the number of followers of that particular record .stored as a custom field on the object

Possible solution i could think of is have a trigger on entity subscription object ?if so where do we write it?so an after insert/before delete trigger should help in updating?

Or can i avoid code at all?

My usecase is on click of a button,multiple chatter files should be downloaded at once.

Due to time constraints we are doing this by JS. Looping through URLS as below.But issue is download does happen but if there are three files.three windows are opened and download happens in separate window.is there a way to collect these and make it a better user experience.

This is the VF page

<apex:actionFunction name="clearitem" action="{!clearitems}" rerender="msgs" />
<apex:outputLink onClick="downloaditem();">
Download
</apex:outputLink>

This is the JS

 

<script type="text/javascript">
function downloaditem()
{
var SFObjectArray = new Array();
<apex:repeat value="{!chatterfileids}" var="arrayItem">
SFObjectArray.push('{!arrayItem}');
</apex:repeat>

var url = '{!url}';


for (var i = 0; i < SFObjectArray.length; i++)
{

window.open(url +SFObjectArray[i] );

}
}

I have an output panel inside my apex:repeat tag.

My requirement is to conditionally display it.

So for one element in apex:repeat this panel might be rendered ..for some not. Rendering condition is,i need to check whether line item occurs in another controller set variable.

I find it difficult because of following reasons;

1)I understand you cannot check whether a set variable contains this element on visualforce page .or is this possible

2) i can see you cannot pass arguments in your rendered attribute.else i could have specify a boolean value for rendered attribute and set the value based on lineitem passed from front end

3)as the set variable is totally unrelated to line item.i cannot simply specify as below

<apex:repeat value="{!Proposals}" var="item">
<apex:outputPanel rendered="{!item.LineCount > 0}">
<li>
<a href="{!$Page.aa_rg_jm_proposal}?id={!item.Proposal.ID}">{!item.Proposal.Name}</a>
<span class="ui-li-count">{!item.LineCount}</span>
</li>
</apex:outputPanel>
</apex:repeat>

 

I have a requirement to download multiple files on a click of visual force button.

i know below will work if its a single file

   <a href="/servlet/servlet.FileDownload?file={!fileId}">

 

any clue about how to gain this for multiple files

We got a community which is being shared by a two different projects.

Landing page of community is different for two different projects

So as to make sure users land on correct pages,
custom urls on communities was suggested option (due to time restriction)

and when i try to create a custom url.i cannot publish it/test it..any idea what to do?

This is how i added custom url,
went to domain management--clicked add domain.gave a domain name

-Do i need to contact salesforce for enabling domain or something-

went to communities, selected force.com link ,next to a particular community
selected custom url->create new
selected domain specified in previous step [Only those domains created by above steps can be selected here]

Query 1.

Currently we don’t have meta data for ‘version history’ accessible via Ant API. So if developer goes to salesforce URL,and make changes directly ,version history is not logged or accessible right now Do you know whether in future releases there is plan for exposing this data via API

Or do you have a completely different suggestion,how we tackle this?

Query 2

Say an object got deployed in UAT sandbox,from a DEV sandbox.

Later this object was deleted from DEV sandbox.and now we want to propagate this change to UAT. Currently as we understand,only standard objects’ deletion can be propagated.For other custom development,we need to login to UAT and delete it manually

Is there anyway we can do this for custom objects(workflows and other custom developments)

Background--trying to develop a release management plan and Continous integration with git,jenkins,eclipse,Ant API

I got a user ,with email id abc@company.com

This person has two different users registered under this same abc@company.com

For one user ,there is federation id (for that reason i presume SSO enabled)

for this second user.,,federation id is not enabled.

Issue is second users' password was reset and a temporary one was generated When second user tries to reset a permanent password,its either logging him out..or saying account locked.

What could be the reason/solution?

I got a sharing rule which is criteria based sharing rule on custom object and it says if

Product Name equals ''

Share with All Partner users

Readonly

This rule works in terms of sharing the records.

But when i try to migrate it using change sets (Just this sharing rule) It gives me An unexpected error occurred. Please include this ErrorId if you contact support: 1748658427-9347 (1893024205)

 

Does anyone know why? Is it because i put '' ? and it takes it as empty value or something?

 am new to Apex and not very sure about how to display message. Here is my use case i need to check whether owner has been changed and a box is checked. and if condition is true should not allow the change. If condition is false should carry on processing.

It is NOT an 'ALL or NONE' case.

Its a before update trigger.

What i am doing below is changing the owner back to previous ,when my condition is true.and ideally i would like to show users list of records for which owner cannot be changed.Not sure whether that is even possible.Or is there a better way to do this?

I need to display this especially mainly when user tries to change ownership via  mass transfership  tool

 

public static void checkOwnerChange(map <ID,account>Triggeroldmap,list<account>Triggerlist){
List<account> toUpdate = new list<account> ();
for (Account accountrecord: Triggerlist){
Account oldaccount = TriggeroldMap.get(accountrecord.ID);
if ((accountrecord.checkbox == true) &&
(GEN_Utilities.recordType(accountrecord.recordTypeId) == 'check Account') &&
(oldaccount.OwnerID != accountrecord.OwnerID))
{
accountrecord.OwnerID = oldaccount.OwnerID ;
//some way to display a message saying this record cannot be changed
}
}
}

 

Is it possible to assign a record type with a visual force page.

I have this usecase,when i change owner to a particular type of user ,record type is updated. This record type should be associated with a page layout of minimum information. As i cannot take standard mandatory fields from a normal page layout,that wont work In short whenever i see this record,it should have only minimum information and should be associated with this particular minimum page Any ideas?

I have a usecase where owners should not be changed for standarad Account object. I put a validation rule for these. and it works as well.But then came across this statement

If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules won’t run on those records.

what does it mean? Does it mean if i use mass transfer tool my validation rule will fail?

I should go for a trigger in this case?

If a trigger is there a way to understand the context is 'mass transfer tool' .so that i can trigger only in that context?

I have a multiselect picklist in my grandparent object.

I have a text field in my object.

Whenever user enters text into this text field ,and after saving i need to check whether my text contains the values defined in picklist


This is mainly for a profanity check .

what is the best way to do this?

I have a usecase ,where i have to traverse through account hierachy and if i find an account with a speical characteristic need to fetch it,else get the top most account in hierarchy.

Limit for level of hierarchy is infinite.

I tried coding this(am new to Apex :(  ),by a recursive kind of function to avoid SOQL hitting.Not sure how efficient below code is.

But i couldnt find an exit kind of function to exit from the recursive calls to get back to trigger in APEX.Is there one?

below is my code.review comments are welcom :)

Code as such works,but when i try to test this against large datasets,its fine for accounts when less than 1000 in numbers,when after 1000 it gives me too many script statement errors,is there a maximum number to test against in testclass,althoguh everywhere it says just 200

Before Trigger on Account

-----------------------

trigger GEN_BeforeInsertUpdate on Account (before insert,before update) {
Account VGEorTopParent = new account();
testclass obj = new testclass();
integer queryLimit = Limits.getLimitQueryRows()-Limits.getQueryRows();
List<account> existingAccounts = [select parentID,Is_VGE_Account__c from Account limit :queryLimit ];
for (Account currAcc :Trigger.new)
{
    //Checking whether current Account has a parent.Only if it has a parent execute all logic
    if (currAcc.ParentId != null)
      {   

         // for(List<Account> acclist :existingAccounts)
             //   {
                 Map<ID, Account> parentMap = new Map<ID, Account>(existingAccounts);
                  //Looping through map values
                  if (!parentMap.isempty())
                  {
                  for (Account acc:parentMap.values())
                  {
                  if (acc.ID == currAcc.parentID)
                  {
                   VGEorTopParent = obj.getnextparent(acc, parentMap);
                   currAcc.Global_Ultimate__c =  VGEorTopParent.ID;
                    break;
                  }
                  }
                                
                }
                 //  }

      }
              
}

}

----------------------------------------------

Class and recursive method

 

public with sharing class testclass {
public account a = new account();
 account s = new account();
     public  Account getnextparent( Account inboundparent,Map<ID,Account>  inboundmap)
    {
       if (!inboundmap.isempty()) 
        {
       
            if (inboundparent.Is_VGE_Account__c)
        {
            inboundmap.clear();
            return (inboundparent);
          
        }
        else
        {
            
            s = inboundmap.get(inboundparent.ParentID);
            if ( s == null)
            {
            inboundmap.clear();
            return (inboundparent);
           
            }
         inboundmap.remove(inboundparent.Id);
         a = getnextparent(s,inboundmap);
         return(a);
          }
   
        }
        else
        {
            return a;
            
        }
        
    }
}

 

 

 

I created a custom button which executes JAVASCRIPT, Depending on whether a detail is present i need to display error message/redirect user.
Is there a way to get the list of related list in JAVASCRIPT without writing a query.
Say for eg;if my JS is on Lead object if i say
lead_record.id = "{!Lead.Id}";
i could get ID directly Similar is there a way to get related lists?
[i could also create a rollup summary and check for this,but want to avoid creation of fields]

I have a usecase which can be either achieved by

1)create a custom button

2)add javascript

3)call apex global webservice class [all apex function to be called from JS should be global webservice]which has the logic of updating database

OR

1)create a custombutton

2)add javascript

3)redirect to a VF page

4)VF extension controller handles logic

Which is a best way to do this?I went for second thinking,more webservices might not be a good thing.But does anyone know what should be the approach to be taken in such cases

I am running below code in anonymous block and i get some weird 'internl error'

cannot figure out why .I am new to apex.please help

public class abcd
{public void m1()
{
system.debug('hi');
}

}
abcd objec = new abcd();
objec.m1();

Hi everyone,

I created a reference variable a.

and instantiated it .

how i thought what happens during instantiation is,

First instantiation->

Account1 got its heap area

Reference Variable 'a' point to 'Account1' memory location

 

Second instantiation->

Account2 got its heap area

reference variable 'a' now repoint to 'Account2'

 

Account 1 is ready for garbage collection.

 

But when i run below code.heap size remains same for second instantiation.how can this be true?where am i going wrong?

 

account a;
System.debug('Current Heap:::' + Limits.getHeapSize());
a = new account(name ='Account1');
System.debug('Current Heap:::' + Limits.getHeapSize());

system.debug(a);
a = new account(name = 'Account2');
System.debug('Current Heap:::' + Limits.getHeapSize());

system.debug(a);

Hi ,

I am trying to do Java script,on click of a custom button.

I am trying to fetch a custom field from another record and check against it

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit
var acc_ID = "{!Lead.Account__c}";
var accounts = sforce.connection.query(
"Select Eligible_for_Deal_registration__c From Account WHERE ID = '" + acc_ID + "'");
var records_accounts = accounts.getArray("records");
var account_eligbility = records_accounts[0].Eligible_for_Deal_registration__c;

 

But giving me this error below. 

Cannot read property Eligible_for_Deal_registration__c of undefined

 

 

 

There is Partner Account field on lead object.

Salesforce says,

DescriptionID of the partner account for the partner user that owns this lead. Available only if Partner Relationship Management is enabled OR Communities is enabled and you have partner portal licenses.

 

Although field says lookup,it looks like will be prepopulated when a partner user creates a lead.

 

Is there any way to get content(ID of account) of this field.

 

When i try Lead.PartnerAccount it says field doesnt exist

 

Does anyone have a clue?.It would be really good to get hold of this field 

Below is my code to update a record when a button is clicked.

Its giving me a error

Faultcode soap env client unexpected element urn partner soap sforce.com done during simple deserialization

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit

var lead_record = new sforce.SObject("Lead"); //creating sobject to hold the values of lead record that this code will ultimately update
lead_record.id = "{!Lead.Id}";
var recTypeName = "Deal Record Type";
var recordType = sforce.connection.query("Select ID, Name From RecordType WHERE Name = 'Deal Registration Record Type'" );
lead_record.RecordTypeId = recordType ;
result = sforce.connection.update([lead_record]); //push the updated records back to Salesforce
alert("Please complete further information on your deal"); //alert the user that their Lead is now able to be edited as a Deal
window.location.reload(); //refresh the page

I have a requirement to download multiple files on a click of visual force button.

i know below will work if its a single file

   <a href="/servlet/servlet.FileDownload?file={!fileId}">

 

any clue about how to gain this for multiple files

We got a community which is being shared by a two different projects.

Landing page of community is different for two different projects

So as to make sure users land on correct pages,
custom urls on communities was suggested option (due to time restriction)

and when i try to create a custom url.i cannot publish it/test it..any idea what to do?

This is how i added custom url,
went to domain management--clicked add domain.gave a domain name

-Do i need to contact salesforce for enabling domain or something-

went to communities, selected force.com link ,next to a particular community
selected custom url->create new
selected domain specified in previous step [Only those domains created by above steps can be selected here]

I got a sharing rule which is criteria based sharing rule on custom object and it says if

Product Name equals ''

Share with All Partner users

Readonly

This rule works in terms of sharing the records.

But when i try to migrate it using change sets (Just this sharing rule) It gives me An unexpected error occurred. Please include this ErrorId if you contact support: 1748658427-9347 (1893024205)

 

Does anyone know why? Is it because i put '' ? and it takes it as empty value or something?

 am new to Apex and not very sure about how to display message. Here is my use case i need to check whether owner has been changed and a box is checked. and if condition is true should not allow the change. If condition is false should carry on processing.

It is NOT an 'ALL or NONE' case.

Its a before update trigger.

What i am doing below is changing the owner back to previous ,when my condition is true.and ideally i would like to show users list of records for which owner cannot be changed.Not sure whether that is even possible.Or is there a better way to do this?

I need to display this especially mainly when user tries to change ownership via  mass transfership  tool

 

public static void checkOwnerChange(map <ID,account>Triggeroldmap,list<account>Triggerlist){
List<account> toUpdate = new list<account> ();
for (Account accountrecord: Triggerlist){
Account oldaccount = TriggeroldMap.get(accountrecord.ID);
if ((accountrecord.checkbox == true) &&
(GEN_Utilities.recordType(accountrecord.recordTypeId) == 'check Account') &&
(oldaccount.OwnerID != accountrecord.OwnerID))
{
accountrecord.OwnerID = oldaccount.OwnerID ;
//some way to display a message saying this record cannot be changed
}
}
}

 

I have a multiselect picklist in my grandparent object.

I have a text field in my object.

Whenever user enters text into this text field ,and after saving i need to check whether my text contains the values defined in picklist


This is mainly for a profanity check .

what is the best way to do this?

Hi everyone,

I created a reference variable a.

and instantiated it .

how i thought what happens during instantiation is,

First instantiation->

Account1 got its heap area

Reference Variable 'a' point to 'Account1' memory location

 

Second instantiation->

Account2 got its heap area

reference variable 'a' now repoint to 'Account2'

 

Account 1 is ready for garbage collection.

 

But when i run below code.heap size remains same for second instantiation.how can this be true?where am i going wrong?

 

account a;
System.debug('Current Heap:::' + Limits.getHeapSize());
a = new account(name ='Account1');
System.debug('Current Heap:::' + Limits.getHeapSize());

system.debug(a);
a = new account(name = 'Account2');
System.debug('Current Heap:::' + Limits.getHeapSize());

system.debug(a);

Hi All,

 

Is there an easy way to update a field on Master record,as a result of approval process on detail object(both custom)

Must be something very silly.But i get an error like this

14:17:59:040 FATAL_ERROR System.QueryException: List has more than 1 row for assignment to SObject

 

for code below

 

List<Contact> mylist = new list<Contact> {[select id from Contact ]};

 

Anyone can spot anything?

Can anyone please explain what is the difference between two code below

 

1.

Account acc1 = new account(name = 'a');

 

2.

 

Account acc1 ;

 acc1 = new account(name = 'a');

 

 

 

In developer console i could see ,variable assignment of acc1 with a memory location ='0X352e62d6' at end of code 1

and at end of code 2,variable assignment of acc1 is null

 

 

Can somebody please explain what below code does

sobject s = new account();

Account a = (Account)s;
object obj = s;

a = (account)obj;

 

 

I am particularly interested in what happens at stack/heap when object obj = s happens.

 

i could see in developer console a [object Object] value for obj.But cannot figure what exactly happens internally or what is the purpose

 

 

Code source is Apex developer guide