• Nishant Singh Panwar
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hi Everyone!

Have anyone Implemented a Joined Report with dynamic parameters and calling that report from a Command Link.

The Joined report contain report from two related objects containining a same field and same filter condition (That too only one condition..).

Sounds pretty simple but it is not working with URL parameter passing.

It will be very helpful if someone can share their inputs.

Thank You.
Nishant Singh
 
Folks, is there any way to get autocomplete with sfdx cli on a windows machine? I have seen beautiful bash scripts for the Mac friends, but nothing for us windows shlubs. 
I will be really appriciate if some one let me know logic of auth provider , I dont want user to create if its already exsiting user . 


global class SocialRegHandler implements Auth.RegistrationHandler{
    
    static final string social_account = 'Social Sign-On';
    static final string community_profile = 'Customer Community User';
    static final string standard_profile  = 'Standard User';
    
    void prepareUserData(Auth.UserData data, User u)
    {   
        String name, firstName, lastName, username, alias, email;

        //TODO: Customize the user attributes. Also check that the username doesn't 
        //already exist and possibly ensure there are enough org licenses to 
        //create a user. Must be 80 characters or less
        
        // Print the attributes list retrieved by the Authentication Provider
        system.debug('Email: ' + data.email);
        system.debug('First Name: ' + data.firstName);
        system.debug('Last Name: ' + data.lastName);
        for(string key : data.attributeMap.keySet())
        {
            system.debug('key: ' + key + ' value: ' + data.attributeMap.get(key));
        }
    
        // Initialize the attributes essential for creating a new user with dummy values 
        // in case they will not be provided by the Auth Provider 
        firstName = 'change-me';
        lastName  = 'change-me';
        email     = 'change@me.com';
       
        if(data.email != null && data.email != '')
            email = data.email;
     
        if(data.firstName != null && data.firstName != '')
            firstName = data.firstName;
       
        if(data.LastName != null && data.lastName != '')
            lastName = data.lastName;

        if(data.attributeMap.containsKey('full_name'))
            name = data.attributeMap.get('full_name');
     
       if(data.attributeMap.containsKey('name'))
           name = data.attributeMap.get('name');

        if(firstName == 'change-me' && name != '')
            firstName = name.substringBefore(' ');

       if(lastName == 'change-me' && name.substringAfter(' ') != '')
           lastName = name.substringAfter(' ');
           
     
        // Generate a random username
        Integer rand = Math.round(Math.random()*100000000);
        username = firstName + '.' + rand + '@social-sign-on.com';        
    
        alias = firstName;
        //Alias must be 8 characters or less
        if(alias.length() > 8)
            alias = alias.substring(0, 8);   
            
        u.username = username;
        u.email = email;
        u.lastName = lastName;
        u.firstName = firstName;
        u.alias = alias;
        u.languagelocalekey = UserInfo.getLocale();
        u.localesidkey = UserInfo.getLocale();
        u.emailEncodingKey = 'UTF-8';
        u.timeZoneSidKey = 'America/Los_Angeles';
    }
    
 // Creates a Standard salesforce or a community user
 global User createUser(Id portalId, Auth.UserData data){
    
    User u = new User();
    
    prepareUserData(data, u);
    
    //TODO: Customize the username, profile and account name
 
    if(data.attributeMap.containsKey('sfdc_networkid')) {
       //We have a community id, so create a user with community access
       
       //TODO: Customize the Account
       Account a;
       List<Account> accounts = [SELECT Id FROM account WHERE name=:social_account];
       if(accounts.isEmpty())
       {
           a = new Account(name = social_account);
           insert(a);
       }else
           a = accounts[0];
      
       Contact c = new Contact();
       c.accountId = a.Id;
  
       c.firstName = u.firstName;
       c.lastName  = u.lastName;
       insert(c);
       
       //TODO: Customize the profile
       Profile p = [SELECT Id FROM profile WHERE name=:community_profile];     
       u.profileId = p.Id;
       u.contactId = c.Id;
       return u;
    } else {
       //TODO: Customize the profile
       Profile p = [SELECT Id FROM profile WHERE name=:standard_profile];
       u.profileId = p.Id;
       return u;
    } 
}
    
// Updates the user's first and last name
global void updateUser(Id userId, Id portalId, Auth.UserData data){
 
  User u = new User(id=userId);
     
  if(data.email != null && data.email != '')
      u.email = data.email;
     
  if(data.lastName != null && data.lastName != '')
    u.lastName = data.lastName;
  
  if(data.firstName != null && data.firstName != '') 
    u.firstName = data.firstName;
  
  update(u);


}
Hi


Please, help to set up proxy for SFDX CLI.

I'm trying:
sfdx update

I'm getting:
If you are behind a proxy, please make sure that the network 'proxy' config is set properly.  See: 'npm help config'

Regards, Aliaksandr Satskou
Hi 

I have an requirement that i am tryong to insert Records in to  object after completing insertation operation i want to display reports in vf page 

For example i am inserted 200 records in to x object after completing operation i want to generate report on insertation of 200 records which are successfully inserted and which records failed to insert

Thanks In Advance
Sampath Palli
Hi Everyone!

Have anyone Implemented a Joined Report with dynamic parameters and calling that report from a Command Link.

The Joined report contain report from two related objects containining a same field and same filter condition (That too only one condition..).

Sounds pretty simple but it is not working with URL parameter passing.

It will be very helpful if someone can share their inputs.

Thank You.
Nishant Singh
 

Hi,

As a complete Javascript novice, I'm trying to get some assistance here with a script to run a report from a button on the Contracts object that will parse some field data to a joined report. You can't do it with a URL hack, has to be javascript.

Luckily, I have some code to work from, it is rather transparent although I need some help amending it.

My issue is with pulling some information from Salesforce into the script, arrays and such things.
 

Essentially the code I have ripped is looking to parse one field, I am looking to parse two (a custom field from the Accounts object (sagecode__c for arguments sake) and one from the Contracts object itself (contractnumber__c for arguments sake).

This is the code, it is from the author so does not contain anything pertaining to what I am aiming to do in my own org. The header comments are mine.

// JScript source code
// This is a script which parses parameters to a Joined Report as URL hacking will not work in this instance.
// Background reading on solution is here: http://salesforce.stackexchange.com/questions/8723/passing-variables-to-joined-reports
// This script was sourced from here: https://gist.github.com/stephenbrown1/7443749
// Chrome extention tools to debug the report from here: http://forums.chrispederick.com/
// -- -- -- Click FORMS and VIEW FORM INFORMATION to find the reportJson details for this script after running report.
// This site URL encodes the JSON request: http://www.freeformatter.com/url-encoder.html
// Code is annotated where you need to make amendments

var url = "/00O90000004ewmO";    // report ID
var method = "POST";
var idArray = {!GETRECORDIDS($ObjectType.Contract_Partner_vod__c)};   // if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get related data
var idToUse = idArray[0];

//alert(idToUse);

if (idToUse == null) {   // need to have at least 1 record selected
alert('You must select one contract partner record to run this report.');
} else {

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

result = sforce.connection.query("Select Id, Contract_vod__c from Contract_Partner_vod__c where Id = \'" + idToUse + "\'");

var contrId = null;

records = result.getArray("records");

for (var i=0; i< records.length; i++) {
var record = records[i];
contrId = record.Contract_vod__c.substring(0,15);
}

//alert(contrId);

// if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get related data - in this case contract ID

// next line is post data - needs to be URL encoded. Note this is based on what comes from the runReportJson which you can get from running the report and checking firebug
var postData = "op=run&runReportJson=%7B%22last_modified_user_id%22%3A%22005900000022hZg%22%2C%22breaks%22%3A%5B%7B%22brkcol%22%3A%2200N90000007QeT8%22%2C%22break%22%3A%2200N90000007QeT8%22%2C%22sortColumn%22%3A%2200N90000007QeT8%22%2C%22brkord%22%3A%22up%22%2C%22breakLevel%22%3A%220%22%2C%22brkdat%22%3A%220%22%7D%5D%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22reln%22%3A%2200N90000007JDQt%22%2C%22currency%22%3A%22000%22%2C%22id%22%3A%2200O90000004ewmO%22%2C%22cust_devName%22%3A%22Contract_Price_List%22%2C%22cust_name%22%3A%22Contract+Price+List%22%2C%22last_modified_by%22%3A%22Paul+Hosking%22%2C%22details%22%3A%22no%22%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22lsk%22%2C%22value%22%3A%221%22%7D%2C%7B%22param%22%3A%22block_id_counter%22%2C%22value%22%3A%226%22%7D%5D%2C%22templateKey%22%3A%2201I900000018lXc00N90000007JDQt%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%5D%2C%22sortdir%22%3A%22down%22%2C%22sideBySide%22%3Afalse%2C%22blocks%22%3A%5B%7B%22templateKey%22%3A%2201I900000018lXc00N90000007JDQt%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22FK_NAME%22%2C%22CUST_NAME%22%2C%2200N90000007QeUH%22%2C%2200N90000007QeT7%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22breaks%22%3A%5B%5D%2C%22a%22%3A%5B%2200N90000007QeT7%22%2C%2200N90000007QeUH%22%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22colorRanges%22%3A%5B%5D%2C%22reln%22%3A%2200N90000007JDQt%22%2C%22format%22%3A%22t%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22v%22%3A142%2C%22cust_name%22%3A%22Contract+Price+Rule%22%2C%22co%22%3A%22no%22%2C%22last_modified_date%22%3A%22%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B1%22%2C%22csfReferences%22%3A%5B%22FORMULA1%22%2C%22FORMULA2%22%2C%22FORMULA3%22%2C%22FORMULA4%22%2C%22FORMULA5%22%2C%22FORMULA6%22%2C%22FORMULA7%22%5D%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%22FK_CUSTENT_ID%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22" + contrId + "%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%2C%7B%22param%22%3A%22save_drill%22%2C%22value%22%3A%22true%22%7D%5D%7D%2C%7B%22templateKey%22%3A%2201I900000018lXc%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22CUST_NAME%22%2C%2200N90000007QeT6%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22breaks%22%3A%5B%5D%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22a%22%3A%5B%2200N90000007QeT6%22%5D%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22format%22%3A%22t%22%2C%22v%22%3A142%2C%22cust_name%22%3A%22List+Price%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22last_modified_date%22%3A%22%22%2C%22co%22%3A%22no%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B0%22%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%22CUST_RECORDTYPE%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22List_Price_Rule_vod%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeUG%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT2%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT1%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%5D%7D%2C%7B%22templateKey%22%3A%2201I900000018lXc%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22CUST_NAME%22%2C%2200N90000007QeUH%22%2C%2200N90000007QeT7%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22breaks%22%3A%5B%5D%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22format%22%3A%22t%22%2C%22v%22%3A142%2C%22cust_name%22%3A%22STT+Price%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22last_modified_date%22%3A%22%22%2C%22co%22%3A%22no%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B3%22%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%2200N90000007QeT2%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT1%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007JDQt%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeUG%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeY2%22%2C%22pn%22%3A%22ge%22%2C%22pv%22%3A%22TODAY%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeTC%22%2C%22pn%22%3A%22le%22%2C%22pv%22%3A%22TODAY%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%22CUST_RECORDTYPE%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22Discount_Rule_vod%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%5D%7D%5D%2C%22format%22%3A%22mb%22%2C%22created_by_user_id%22%3A%22005900000022hZg%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22v%22%3A142%2C%22last_modified_date%22%3A%2214%2F11%2F2013+9%3A49+AM%22%2C%22co%22%3A%22yes%22%2C%22customAggregates%22%3A%5B%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22List+Price+List+Price%22%2C%22DeveloperName%22%3A%22FORMULA1%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Disc%22%2C%22DeveloperName%22%3A%22FORMULA2%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Net%22%2C%22DeveloperName%22%3A%22FORMULA3%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Disc+Net+Price%22%2C%22DeveloperName%22%3A%22FORMULA4%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Contract+Disc+Net+Price%22%2C%22DeveloperName%22%3A%22FORMULA5%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22IF%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%3C%3E0%5Cn%2C+B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%5Cn%2C+IF%28B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%3C%3E0%5Cn%2C%28B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%29+%2F+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%3C%3E0%5Cn%2CB3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%3C%3E0%5Cn%2C+%28B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%29%2FB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%2C0%5Cn%29%29%29%29%22%2C%22DataType%22%3A%22P%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Final+Discount%22%2C%22DeveloperName%22%3A%22FORMULA6%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22IF%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+%3C%3E+0%5Cn%2C+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%5Cn%2C+IF%28B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG+%3C%3E+0%5Cn%2CB1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+%3C%3E+0%5Cn%2CB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG+%3C%3E+0%5Cn%2CB3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%5Cn%2CB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%29%29%29%29%22%2C%22DataType%22%3A%22C%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Final+Net%22%2C%22DeveloperName%22%3A%22FORMULA7%22%2C%22Scale%22%3A2%7D%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%7D%2C%22rt%22%3A%2251%22%2C%22cust_owner%22%3A%2200D90000000ome4%22%7D&repId=00O90000004ewmO";

// You REALLY want async = true.
// Otherwise, it'll block ALL execution waiting for server response.
var async = true;

var request = new XMLHttpRequest();




// Before we send anything, we first have to say what we will do when the
// server responds. This seems backwards (say how we'll respond before we send
// the request? huh?), but that's how Javascript works.
// This function attached to the XMLHttpRequest "onload" property specifies how
// the HTTP response will be handled.
request.onload = function () {

// Because of javascript's fabulous closure concept, the XMLHttpRequest "request"
// object declared above is available in this function even though this function
// executes long after the request is sent and long after this function is
// instantiated. This fact is CRUCIAL to the workings of XHR in ordinary
// applications.

// You can get all kinds of information about the HTTP response.

var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
var data = request.responseText; // Returned data, e.g., an HTML document.
var x=window.open().document;
x.open();
x.write(data);
x.close();

}

request.open(method, url, async);

request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// Or... request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
// Or... whatever

// Actually sends the request to the server.
request.send(postData);
}
I can see what is going on, array is being created, SoQL query executing, value being stored. But there are some elements I am not sure of:

var idArray = {!GETRECORDIDS($ObjectType.Contract_Partner_vod__c)};   // if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get

Unsure of the syntax I use here. I'm obviously to get ID's from an object to use in a query, I just need to know if I'm going to be formatting it correctly. I would ask our Java guys but I think this falls into the realm of Salesforce syntax.

records = result.getArray("records");

for (var i=0; i< records.length; i++) {
var record = records[i];
contrId = record.Contract_vod__c.substring(0,15);
}

Not sure what this piece of the code is aiming to do either. Is it truncating the 18 character ID? Because if so, I can probably kill this section of code off as I will be purely dealing with strings.



The rest seems relatively straightforward, it looks like I would have to duplicate the code to find my second field to parse. This person is obviously looking for his one custom field to parse to the report, as reflected by the search and result obtained.

Can anyone shed some light here to help me through?

Thanks.

I'd like to create a custom link on the account page, which will link to a report. However, I want the report to only show values for that particular account. For instance, it would show all the activities for that account categorized by type of activity. I'm not sure how to use a link to dynamically customize a report like that. 

I can't figure out how to do this, and SF support sent me here... 

 

Thanks!
Ariel

  • March 27, 2010
  • Like
  • 0
I will be really appriciate if some one let me know logic of auth provider , I dont want user to create if its already exsiting user . 


global class SocialRegHandler implements Auth.RegistrationHandler{
    
    static final string social_account = 'Social Sign-On';
    static final string community_profile = 'Customer Community User';
    static final string standard_profile  = 'Standard User';
    
    void prepareUserData(Auth.UserData data, User u)
    {   
        String name, firstName, lastName, username, alias, email;

        //TODO: Customize the user attributes. Also check that the username doesn't 
        //already exist and possibly ensure there are enough org licenses to 
        //create a user. Must be 80 characters or less
        
        // Print the attributes list retrieved by the Authentication Provider
        system.debug('Email: ' + data.email);
        system.debug('First Name: ' + data.firstName);
        system.debug('Last Name: ' + data.lastName);
        for(string key : data.attributeMap.keySet())
        {
            system.debug('key: ' + key + ' value: ' + data.attributeMap.get(key));
        }
    
        // Initialize the attributes essential for creating a new user with dummy values 
        // in case they will not be provided by the Auth Provider 
        firstName = 'change-me';
        lastName  = 'change-me';
        email     = 'change@me.com';
       
        if(data.email != null && data.email != '')
            email = data.email;
     
        if(data.firstName != null && data.firstName != '')
            firstName = data.firstName;
       
        if(data.LastName != null && data.lastName != '')
            lastName = data.lastName;

        if(data.attributeMap.containsKey('full_name'))
            name = data.attributeMap.get('full_name');
     
       if(data.attributeMap.containsKey('name'))
           name = data.attributeMap.get('name');

        if(firstName == 'change-me' && name != '')
            firstName = name.substringBefore(' ');

       if(lastName == 'change-me' && name.substringAfter(' ') != '')
           lastName = name.substringAfter(' ');
           
     
        // Generate a random username
        Integer rand = Math.round(Math.random()*100000000);
        username = firstName + '.' + rand + '@social-sign-on.com';        
    
        alias = firstName;
        //Alias must be 8 characters or less
        if(alias.length() > 8)
            alias = alias.substring(0, 8);   
            
        u.username = username;
        u.email = email;
        u.lastName = lastName;
        u.firstName = firstName;
        u.alias = alias;
        u.languagelocalekey = UserInfo.getLocale();
        u.localesidkey = UserInfo.getLocale();
        u.emailEncodingKey = 'UTF-8';
        u.timeZoneSidKey = 'America/Los_Angeles';
    }
    
 // Creates a Standard salesforce or a community user
 global User createUser(Id portalId, Auth.UserData data){
    
    User u = new User();
    
    prepareUserData(data, u);
    
    //TODO: Customize the username, profile and account name
 
    if(data.attributeMap.containsKey('sfdc_networkid')) {
       //We have a community id, so create a user with community access
       
       //TODO: Customize the Account
       Account a;
       List<Account> accounts = [SELECT Id FROM account WHERE name=:social_account];
       if(accounts.isEmpty())
       {
           a = new Account(name = social_account);
           insert(a);
       }else
           a = accounts[0];
      
       Contact c = new Contact();
       c.accountId = a.Id;
  
       c.firstName = u.firstName;
       c.lastName  = u.lastName;
       insert(c);
       
       //TODO: Customize the profile
       Profile p = [SELECT Id FROM profile WHERE name=:community_profile];     
       u.profileId = p.Id;
       u.contactId = c.Id;
       return u;
    } else {
       //TODO: Customize the profile
       Profile p = [SELECT Id FROM profile WHERE name=:standard_profile];
       u.profileId = p.Id;
       return u;
    } 
}
    
// Updates the user's first and last name
global void updateUser(Id userId, Id portalId, Auth.UserData data){
 
  User u = new User(id=userId);
     
  if(data.email != null && data.email != '')
      u.email = data.email;
     
  if(data.lastName != null && data.lastName != '')
    u.lastName = data.lastName;
  
  if(data.firstName != null && data.firstName != '') 
    u.firstName = data.firstName;
  
  update(u);


}