• Kiyana Dunlock
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
I have custom metadata where the labels are the names of the Account.
I want a formula field on the Account object that returns the prelog agency feld value associated with the custom metadata with the Account name label
Ex:
 $CustomMetadata.Agency_Match_Error_Accounts__mdt.Case_Legal_Media.Prelog_Agency__c 

Case_Legal_Media is the name of an account and the name of the custom metadata label. I want to insert this dynamically such as !{Account.Name} but unsure of syntax.
I have two fields on the Account -
Account Name and Account Alias

I have a list of Account names and their Aliases that I would like to be able to store in salesforce somewhere to reference.

I want a formula field check box that checks these values against the list.

I want the formula to find the Account Name Field in the Account Name keys from the list and check if the value = the Alias field and if so return true.
Hi!

I am trying to create a formula field checkbox that checks if a value in a field on the record and on the parent record(master) is a part of the list.

Ex.
Master Record Child Name Field - 'A'
Child Record Name Field - 'B'

UniqueCases List ex.
master record chld name.      child recod name 
              'A'                                          'B'

Example formula

AND(masterRecordChildName != childRecodName , !Contains(UniqueCases.masterRecordChildName,  MasterRecordChildNameField), !Contains(UniqueCases.childRecodName,  ChildRecodNameField))
Hi Team!!

Currently the first SOQL is working but when I update the dates and click submit I still see the same list of schedules even though they are not in the range.  Was trying to get the start week working in my code first but I need both start and end. 
 
VF Page
<apex:page standardController="Schedules__c" extensions="WeeklyComparisonController">
<script>
function toggleContacts(className){
    elem = document.getElementsByClassName(className)[0];
    if(elem.style.display == 'none')
        elem.style.display = 'block';
    else
        elem.style.display = 'none';
}
</script>
<apex:form >
<apex:panelGrid columns="5" id="dates1">
    <b>Start Date: </b><apex:inputfield value="{!firstRangeWeek.Week__c}"/>
    <b>End Date: </b><apex:inputfield value="{!Schedules__c.Week__c}"/>
    <apex:commandButton value="Submit" rerender="dates1, case"/>

</apex:panelGrid>
<apex:outputPanel id="test">  
    <apex:repeat value="{!sched}" var="s" id="scheds">
        <apex:pageBlock title="{!s.Name} {!s.Week__c} ({!s.ID})">
            Data
        </apex:pageBlock>
    </apex:repeat>
</apex:outputPanel>
</apex:form>
</apex:page>


 
Controller
 
public class WeeklyComparisonController {
    public Schedules__c firstRangeWeek{get; set;}

    public WeeklyComparisonController(ApexPages.StandardController sc){
        firstRangeWeek = new Schedules__c(Week__c = date.today().toStartofWeek().AddDays(-6));
    }
    public Schedules__c[] sched { 	
        get {
            return [
                    SELECT Id, Name, Week__c 
                    FROM Schedules__c
                    WHERE DealProgram__c = 'ION Television'
                    AND Week__c >= :date.valueOf(firstRangeWeek.Week__c)
                    ];
        }
    }
}

I know I need an action with the Submit but Im not sure how to set it up. I tries this and recieved numerous erros:

User-added imageUser-added image
Hi I need help creaating a test class for a visula force page controller, below is the code:

VF Page:
<apex:page controller="AvailabilityReportSyndication" title="Syndication Availability Report">
    <apex:form id="frm">
        <apex:actionStatus id="status1" startText="Saving..." startStyle="font-size:18px"/>
        <apex:sectionHeader title="Availability Report Syndication"/>
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" reRender="frm" status="status1"/>
            </apex:pageBlockButtons>
            <table>
                <tr>
                    <h2><td width = "300px" bgcolor="grey"><B>Program: Program </B></td>
                    <td width = "100px" bgcolor="grey"><B>Units Available </B></td>
                    <td width = "100px" bgcolor="grey"><B>Schedule </B></td></h2>
                </tr>
            
                <apex:repeat value="{!programTeams}" var="obj">
                    <tr>
                        <td colspan="3" bgcolor="{!if(obj.team == 'Blue','Sky Blue',obj.team)}"><B>Program: Team: </B>{!obj.team}<B> ({!obj.tCount} Records)</B></td>
                        <apex:repeat value="{!obj.weeks}" var="w">
                            <tr>
                                <td colspan="3" bgcolor="cyan"><B>Week: </B>
                                    <apex:outputText value="{0,date,MM/dd/yyyy}">
                                        <apex:param value="{!w.week}"/>
                                    </apex:outputText>
                                    <B>({!w.wCount} Records)</B>
                                </td>
                                <apex:repeat value="{!w.schList}" var="s">
                                    <tr>
                                        <td><apex:outputField value="{!s.DealProgram__c}"/></td>
                                        <td align="center"><apex:inputField value="{!s.Units_Available__c}" style="width:50px" /></td>
                                        
                                        <td align="center">
                                            <a href="/{!s.id}" target="_blank">
                                                <apex:outputField value="{!s.Name}"/>
                                            </a>
                                        </td>
                                    </tr>
                                </apex:repeat>
                            </tr>
                        </apex:repeat>
                    </tr>
                </apex:repeat>
                <tr>
                    <td colspan="3" bgcolor="grey"><B>Grand Totals ({!grand} Records)</B></td>
                </tr>
            </table>

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

Controller:
 
public class AvailabilityReportSyndication 
{
    public List<schedules__c> schedules;
    public List<programTeamModel> programTeams{get;set;}
    public Integer grand{get;set;}
    
    //Constructor definition
    public AvailabilityReportSyndication ()
    {
        getRecords();
    }
    private void getRecords() 
    {
    	programTeams = new List<programTeamModel>();
        schedules = [SELECT 
                        id, name, Week__c, Units_Available__c, Rate__c, DealProgram__c, Deal_Parent__c, 
                        Deal_Parent__r.Program__r.Team__c, DealBrand__c, Deal_Parent__r.Program__r.Cable_Synd__c 
                        FROM Schedules__c
                        WHERE Week__c >= LAST_N_DAYS:7 AND DealBrand__c = 'Availability' AND Deal_Parent__r.Program__r.Cable_Synd__c = 'Syndication' 
                        AND Deal_Parent__r.Program__r.Fixed_Inventory__c = false ORDER BY week__c LIMIT 1000
                    ];
        // 
        System.debug('######Records found==>'+schedules.size()+'###'+schedules);

        Map<String, Map<Date, List<Schedules__c>>> teamMap = new Map<String, Map<Date, List<Schedules__c>>>();
        for(Schedules__c sch: schedules)
        {
            if(sch.Deal_Parent__r.Program__r.Team__c != null)
            {
                Map<Date, List<Schedules__c>> weekMap = teamMap.get(sch.Deal_Parent__r.Program__r.Team__c);
                if(weekMap != null)
                {
                    List<Schedules__c> scheds = weekMap.get(sch.Week__c);
                    if(scheds != null)
                    {
                        scheds.add(sch);
                    }else
                    {
                        weekMap.put(sch.Week__c, new List<Schedules__c>{sch});
                    }
                }
                else
                {
                    weekMap = new Map<Date, List<Schedules__c>>();
                    weekMap.put(sch.Week__c, new List<Schedules__c>{sch});
                    teamMap.put(sch.Deal_Parent__r.Program__r.Team__c, weekMap);
                }
            }
        }
        grand = 0;
        for(String t : teamMap.keySet())
        {
            programTeamModel ptm = new programTeamModel();
            ptm.team = t;
            Map<Date, List<Schedules__c>> wMap = teamMap.get(t);
            
            List<Date> lstDates = new List<Date>();
            List<weekModel> wModelList = new List<weekModel>();
            integer i=0;
            lstDates.addAll(wMap.keySet());
            lstDates.sort();
            for(Date d : lstDates)
            {
              	weekModel wModel = new weekModel();
                List<Schedules__c> s = wMap.get(d);
                wModel.week = d;
                wModel.schList = s;
                wModelList.add(wModel);
                wModel.wCount = s.size();
                i += wModel.wCount;
            }
            ptm.weeks = wModelList;
            ptm.tCount = i;
            programTeams.add(ptm);
            grand += ptm.tCount;
        }
        
    }
    public void save() 
    {
        Set<Schedules__c> updatedSch = new Set<Schedules__c>();
        List<Schedules__c> updatedSchList = new List<Schedules__c>();
        for(programTeamModel p : programTeams)
        {
            List<weekModel> weekList = p.weeks;
            for(weekmodel w : weekList)
            {
                List<schedules__c> sList = w.schList;
                for(Schedules__c s : sList)
                {
                    updatedSch.add(s);
                }
            }
        }
        for(Schedules__c s:updatedSch)
        {
            updatedSchList.add(s);
        }
        upsert updatedSchList;
        system.debug('@@@@@@ Records saved####');
        getrecords();
    }
    class weekModel 
    {
        public integer wCount{get;set;}
        public Date week {get;set;}
        public List<Schedules__c> schList {get;set;}
        public weekModel()
        {
            schList = new List<Schedules__c>();
        }
    }
    class programTeamModel 
    {
        public Integer tCount{get;set;}
        public String team {set;get;}
        public List<weekModel> weeks {get;set;}
        public programTeamModel()
        {
            weeks = new List<weekModel>();
        }
    }
}

Please help thank you!
I have two fields on the Account -
Account Name and Account Alias

I have a list of Account names and their Aliases that I would like to be able to store in salesforce somewhere to reference.

I want a formula field check box that checks these values against the list.

I want the formula to find the Account Name Field in the Account Name keys from the list and check if the value = the Alias field and if so return true.