• Ken sfdc1
  • NEWBIE
  • 130 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 30
    Replies
 I need a calculating field ---  calculate days taken to change from open to verified status.

There is a Lead Status picklist  on Account object   -- open ---> Verified.
.
Let me know if you need more info.
HI,

  Can anyone help me how to acheive this I tried a formula field --
If the related to is a case record then it needs to populate case record type on task record.

Let me know if you understood it.

am trying for an auto fill button but I see something is missing.
Lower registry object -- is a look up to account object 
Iam creating a custom button on Account while they navigate to lower registery new button to that object they want the primary address fields auto filled --- Address line 1, city,state,country etc.
Here is the tricky address is one more object which is master detail to account and there is no relation to Lower registry object.
So i want lower registry --> lookup to account --> master detail to Address object how to get the address from address object to lower registry.
!Address_vod__c.Address_line_2_vod__c is this right or Account__r.Address_vod__c.Address_line_2_vod__c?


https://cs8.salesforce.com/a2I/e?CF00NE0000004vDME={!Account.Name}&00NE0000004vDMF={!Address_vod__c.Name}&00NE0000004vDMG={!Address_vod__c.Address_line_2_vod__c}&00NE0000004vDMI={!Address_vod__c.City_vod__c}&00NE0000004vDMX={!Address_vod__c.State_vod__c}&00NE0000004vDMZ={!Address_vod__c.Zip_vod__c}
 

am trying for an auto fill button but I see something is missing.
Lower registry object -- is a look up to account object 
Iam creating a custom button on Account while they navigate to lower registery new button to that object they want the primary address fields auto filled --- Address line 1, city,state,country etc.
Here is the tricky address is one more object which is master detail to account and there is no relation to Lower registry object.
So i want lower registry --> lookup to account --> master detail to Address object how to get the address from address object to lower registry.
!Address_vod__c.Address_line_2_vod__c is this right or Account__r.Address_vod__c.Address_line_2_vod__c?
Anytime addresses it must take only the address has primary checkbox checked from address object?

a2I/e?CF00NE0000004vDME={!Account.Name}&00NE0000004vDMF={!Address_vod__c.Name}&00NE0000004vDMG={!Address_vod__c.Address_line_2_vod__c}&00NE0000004vDMI={!Address_vod__c.City_vod__c}&00NE0000004vDMX={!Address_vod__c.State_vod__c}&00NE0000004vDMZ={!Address_vod__c.Zip_vod__c}
 
trigger CountSpeakerEvaluationsnew on Speaker_Evaluation_AEGR__c(after insert, after delete, after undelete) {

    List<id> accIdList = new List<id>();
    if(Trigger.isInsert || Trigger.isUndelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.new){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    if(Trigger.isDelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.old){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    List<Account> accUpdateList = new List<Account>();
    For(Medical_Event_vod__c acc : [SELECT  No_of_Speaker_Evaluations__c,(SELECT id FROM Speaker_Evaluations__r) FROM Medical_Event_vod__c WHERE id =: accIdList]){
        acc.No_of_Speaker_Evaluations__c = acc.Speaker_Evaluations__c.size();
        accUpdateList.add(acc);
    }
    try{
        update accUpdateList;
    }Catch(Exception e){
        System.debug('Exception :'+e.getMessage());
    }
}
Error: Compile Error: Invalid foreign key relationship: Speaker_Evaluation_AEGR__c.Medical_Event_vod__c at line 6 column 27
trigger CountSpeakerEvaluationsnew on Speaker_Evaluation_AEGR__c(after insert, after delete, after undelete) {

    List<id> accIdList = new List<id>();
    if(Trigger.isInsert || Trigger.isUndelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.new){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    if(Trigger.isDelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.old){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    List<Account> accUpdateList = new List<Account>();
    For(Medical_Event_vod__c acc : [SELECT  No_of_Speaker_Evaluations__c,(SELECT id FROM Speaker_Evaluations__r) FROM Medical_Event_vod__c WHERE id =: accIdList]){
        acc.No_of_Speaker_Evaluations__c = acc.Speaker_Evaluations__c.size();
        accUpdateList.add(acc);
    }
    try{
        update accUpdateList;
    }Catch(Exception e){
        System.debug('Exception :'+e.getMessage());
    }
}


Error: Compile Error: Invalid foreign key relationship: Speaker_Evaluation_AEGR__c.Medical_Event_vod__c at line 6 column 27
 
please follow this workflow we are trying to create a formula of patient ID by a trigger with the combination of these conditions and fields.We are going for trigger because AEGR_Patient_Initials__c field is converted to encrypted field which is not possible in workflow.

Condition Created and every time edited.
AND(ISPICKVAL($User.AEGR_User_Country__c,"Brazil"),
OR(ISPICKVAL(AEGR_Product__c , "Lomitapide"),
ISPICKVAL(AEGR_Product__c , "Metreleptin"),
ISPICKVAL(AEGR_Product__c , "")),ISPICKVAL( AEGR_Status__c,"Identified" ))

Object : Patient Profile    
Field to Update Patient Profile: Patient ID
Formula value:
IF(ISPICKVAL(AEGR_Product__c , "Lomitapide"), 
AEGR_Patient_Initials__c & "-" & "LOM-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c , "Metreleptin"), 
AEGR_Patient_Initials__c & "-" & "MET-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c ,""),"", 

please follow this workflow we are trying to create a formula of patient ID by a trigger with the combination of these conditions and fields.We are going for trigger because AEGR_Patient_Initials__c field is converted to encrypted field which is not possible in workflow.
Condition Created and every time edited.
AND(ISPICKVAL($User.AEGR_User_Country__c,"Brazil"),
OR(ISPICKVAL(AEGR_Product__c , "Lomitapide"),
ISPICKVAL(AEGR_Product__c , "Metreleptin"),
ISPICKVAL(AEGR_Product__c , "")),ISPICKVAL( AEGR_Status__c,"Identified" ))

Object : Patient Profile    
Field to Update Patient Profile: Patient ID
Formula value:
IF(ISPICKVAL(AEGR_Product__c , "Lomitapide"), 
AEGR_Patient_Initials__c & "-" & "LOM-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c , "Metreleptin"), 
AEGR_Patient_Initials__c & "-" & "MET-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c ,""),"", 
 
Can anyone help me to create a small trigger on Patient Profile object:

Condition Created and every time edited.
AND(ISPICKVAL($User.AEGR_User_Country__c,"Brazil"),
OR(ISPICKVAL(AEGR_Product__c , "Lomitapide"),
ISPICKVAL(AEGR_Product__c , "Metreleptin"),
ISPICKVAL(AEGR_Product__c , "")),ISPICKVAL( AEGR_Status__c,"Identified" ))

Object : Patient Profile    
Field to Update Patient Profile: Patient ID
Formula value:
IF(ISPICKVAL(AEGR_Product__c , "Lomitapide"), 
AEGR_Patient_Initials__c & "-" & "LOM-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c , "Metreleptin"), 
AEGR_Patient_Initials__c & "-" & "MET-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c ,""),"", 
"")))

 
I create a formula field to get account email onto child custom object CCM email but to send an email alert this formula field is not available in the list of email alert so i created a new email field the i want one more workflow for this field update

formula is NOT(ISBLANK(CCM User)) but it is not firing as it is a formula field gets copied directly there is not insert or edit criteria met.

Can anyone help me how ti update this new email field from thia formula field?
The criteria is :

Whenever Refills remaining field changed and if refill remaining is 1 or 0 i want a task alert for that rearrange this formula:

AND(ISCHANGE( Refills_Remaining__c ),((Refills_Remaining__c = 1)) OR
(Refills_Remaining__c = 0))))
Hi Can anyone please add a try catch block for this trigger.


trigger UpdateAttemptsWithCase on Task (after insert, after update, after delete)
{
    Set<String> caseIds = new Set<String>();
    Set<String> taskIds = new Set<String>();
    Set<String> caseTaskIds = new Set<String>();
    
    if(Trigger.isInsert || Trigger.isUpdate)
    {
        for(Task t : Trigger.new)
        {
            if(Trigger.isInsert)
            {
                if(t.WhatId != null && validWhatId(t.WhatId))
                {
                    caseIds.add(t.WhatId);
                    caseTaskIds.add(t.WhatId);
                    taskIds.add(t.Id);
                }
            }
            else
            {
                Task oldTask = (Task)Trigger.oldMap.get(t.Id);
                if(t.WhatId != null && validWhatId(t.WhatId))
                {
                    caseIds.add(t.WhatId);
                }
                if(oldTask.WhatId != null && validWhatId(oldTask.WhatId))
                {
                    caseIds.add(oldTask.WhatId);
                }
                if(t.WhatId != oldTask.WhatId)
                {
                    caseTaskIds.add(t.WhatId);
                    taskIds.add(t.Id);
                }
            }
        }
    }
    else
    {
        for(Task t : Trigger.old)
        {
            if(t.WhatId != null && validWhatId(t.WhatId))
            {
                caseIds.add(t.WhatId);
            }
        }
    }
    List<Case> cases = new List<Case>();
    RecordType rt = [select Id from RecordType where Name = 'Adherence Call' and sObjectType = 'Case'];
    
    for(Case c : [select Attempts__c, (select Id,Subject,status from Tasks where (Subject = 'Call to Patient' or Subject = 'Call from Patient') and status = 'Completed') from Case where Id in :caseIds and recordTypeId = :rt.Id])
    {
        c.Attempts__c = c.Tasks.size();
        cases.add(c);
    }
    
    if(cases.size() > 0)
    {
        update cases;
    }
    
    
    List<Task> tasks = new List<Task>();
    for(Case c : [select ContactId, (select WhoId from Tasks where (Subject='Compass Approval Expiration' or Subject = 'Compass Copay End Date') and Id in :taskIds) from Case where Id in :caseTaskIds])
    {
        for(Task taskInfo : c.Tasks)
        {
            taskInfo.WhoId = c.ContactId;
            tasks.add(taskInfo);
        }
    }
    if(tasks.size() > 0)
    {
        update tasks;
    }
    
    private Boolean validWhatId(String val)
    {
        if(val.substring(0, 3) == '500')
        {
            return true;
        }
        return false;
    }
}
AND( 
RecordTypeId = "012E0000000NA5Q"&& 
(ISPICKVAL( Type__c, "CCM")&& 
ISNULL(Ship_Date__c))&& 

OR(NOT( 
ISPICKVAL(Outcome__c, "Left Message")), 
NOT(ISPICKVAL(Outcome__c,"Unable to Reach")), 
NOT(ISPICKVAL(Outcome__c,"Completed,Patient Started")), 
NOT(ISPICKVAL(Outcome__c,"Completed,Patient has not Started")), 
NOT(ISPICKVAL(Outcome__c,"Not ready for re-order")), 
NOT(ISPICKVAL(Outcome__c,"Patient will call Pharmacy"))))

Ship Date should only be used when Transferred to Pharmacy or Patient Scheduled Delivery are chosen outcomes  

I want a validation for ship date field whenever outcomes are only transferred to Pharmacy or patient Scheduled.It is not working can you help me.
AND(ISPICKVAL(Juxtapid_Policy_Available__c,"Yes"),ISBLANK( TEXT(Juxtapid_PA_Expiration__c )),ISBLANK( TEXT(Parental_LDL_C_History__c )),ISBLANK( TEXT(GT_Jux__c )),  ISBLANK( TEXT(Apheresis_Jux__c)),ISBLANK( TEXT(Xanthomas_Jux__c)),ISBLANK( TEXT(PCSK9_Step_Details__c)),ISBLANK( TEXT(Tried_and_Failed__c)),ISBLANK( TEXT(Corneal_Arcus__c)),ISBLANK( TEXT(Kynamro_Step__c)),ISBLANK( TEXT(R_S__c)))

Each and every must be filled if policy available is yes but it is working only when all fields are blank even if 1 field is not filled we need it to fire.

Something wrong in the validation can anyone correct it.
AND ( RecordTypeId = '012E0000000NA5Q' , ISPICKVAL ( Type__c, "CCM")ISBLANK(Ship_Date__c),OR((ISPICKVAL(Outcome__c, "Patient Scheduled Delivery"), ISPICKVAL(Outcome__c,"Transferred to Pharmacy"))

Error is Syntax error. Missing ')'

·        "Active Persistence Status" picklist from case -- adherence record type update on Account record
·        1. On Drug - Will Re-Order
·        2. On Drug - Unlikely to Re-Order
·        3. Not on Drug - Unlikely to Re-Start
Trigger CaseAfterInsertUpdate on Case (after insert, after update) {
    Set<String> caseIds = new Set<String>();
    
    for (Case c : Trigger.new)
    {
        if(Trigger.isInsert)
        {
            caseIds.add(c.Id);
        }
        else
        {
            Case oldCase = Trigger.oldMap.get(c.Id);
            if(oldCase.Nutrition_Consult_Dietitian__c != c.Nutrition_Consult_Dietitian__c)
            {
                caseIds.add(c.Id);
            }
        }
    }
    
    RecordType rt = [select Id from RecordType where Name = 'Nutrition Consult' and sObjectType = 'Case'];
    
    Map<String, String> AccountMap = new Map<String, String>();
    for(Case c : [select Nutrition_Consult_Dietitian__c, AccountId from Case where Id in :caseIds and (Type = 'Initial' or Type = 'Follow Up')  and  RecordTypeId = :rt.Id])
    {
        AccountMap.put(c.AccountId, c.Nutrition_Consult_Dietitian__c);
    }
    List<Account> accounts = new List<Account>();
    for(Account acc : [select Id, RD_Consult__c from Account where Id in :AccountMap.keySet()])
    {
        acc.RD_Consult__c = AccountMap.get(acc.Id);
        accounts.add(acc);
    }
    
    try {
        update accounts;
    } catch (Exception ex) {
        System.debug('Could not update Last Survey Sent field on Account with cause: ' + ex.getCause());
    }
}

Add the logic to this trigger pls
AND ( RecordTypeId = '012E0000000NA5U' , ISBLANK ( Date__c ) , ISPICKVAL ( Status , "Completed" ) )
AND( RecordTypeId = '012L00000000iir',  (Account.Last_Ship_Date__c  > CreatedDate),
ISPICKVAL(Account.AEGR_Pharmacy_Status__c,"Active"),  ISPICKVAL(StageName,"Shipped"))

Can anyone help me on how to add created date in this validation.
I have 2 requirements of trigger

1. SR date field on Case of record type nutrition consult when it is filled it must be updated to account record with SR date field.
2. There must be a validation of before insert when a new case record is created then if the SR date field on account record is filled then they cannot create a new case record type of nutrition consult with type = initial.

Can anyone help in creating a child to parent update of a date field and also a validation like this  by a trigger.
I want to elimiate this Compass copay visiUser-added imageble when they new button for record type selection.
 I need a calculating field ---  calculate days taken to change from open to verified status.

There is a Lead Status picklist  on Account object   -- open ---> Verified.
.
Let me know if you need more info.
please follow this workflow we are trying to create a formula of patient ID by a trigger with the combination of these conditions and fields.We are going for trigger because AEGR_Patient_Initials__c field is converted to encrypted field which is not possible in workflow.

Condition Created and every time edited.
AND(ISPICKVAL($User.AEGR_User_Country__c,"Brazil"),
OR(ISPICKVAL(AEGR_Product__c , "Lomitapide"),
ISPICKVAL(AEGR_Product__c , "Metreleptin"),
ISPICKVAL(AEGR_Product__c , "")),ISPICKVAL( AEGR_Status__c,"Identified" ))

Object : Patient Profile    
Field to Update Patient Profile: Patient ID
Formula value:
IF(ISPICKVAL(AEGR_Product__c , "Lomitapide"), 
AEGR_Patient_Initials__c & "-" & "LOM-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c , "Metreleptin"), 
AEGR_Patient_Initials__c & "-" & "MET-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c ,""),"", 
The criteria is :

Whenever Refills remaining field changed and if refill remaining is 1 or 0 i want a task alert for that rearrange this formula:

AND(ISCHANGE( Refills_Remaining__c ),((Refills_Remaining__c = 1)) OR
(Refills_Remaining__c = 0))))
AND( 
RecordTypeId = "012E0000000NA5Q"&& 
(ISPICKVAL( Type__c, "CCM")&& 
ISNULL(Ship_Date__c))&& 

OR(NOT( 
ISPICKVAL(Outcome__c, "Left Message")), 
NOT(ISPICKVAL(Outcome__c,"Unable to Reach")), 
NOT(ISPICKVAL(Outcome__c,"Completed,Patient Started")), 
NOT(ISPICKVAL(Outcome__c,"Completed,Patient has not Started")), 
NOT(ISPICKVAL(Outcome__c,"Not ready for re-order")), 
NOT(ISPICKVAL(Outcome__c,"Patient will call Pharmacy"))))

Ship Date should only be used when Transferred to Pharmacy or Patient Scheduled Delivery are chosen outcomes  

I want a validation for ship date field whenever outcomes are only transferred to Pharmacy or patient Scheduled.It is not working can you help me.
AND(ISPICKVAL(Juxtapid_Policy_Available__c,"Yes"),ISBLANK( TEXT(Juxtapid_PA_Expiration__c )),ISBLANK( TEXT(Parental_LDL_C_History__c )),ISBLANK( TEXT(GT_Jux__c )),  ISBLANK( TEXT(Apheresis_Jux__c)),ISBLANK( TEXT(Xanthomas_Jux__c)),ISBLANK( TEXT(PCSK9_Step_Details__c)),ISBLANK( TEXT(Tried_and_Failed__c)),ISBLANK( TEXT(Corneal_Arcus__c)),ISBLANK( TEXT(Kynamro_Step__c)),ISBLANK( TEXT(R_S__c)))

Each and every must be filled if policy available is yes but it is working only when all fields are blank even if 1 field is not filled we need it to fire.

Something wrong in the validation can anyone correct it.

·        "Active Persistence Status" picklist from case -- adherence record type update on Account record
·        1. On Drug - Will Re-Order
·        2. On Drug - Unlikely to Re-Order
·        3. Not on Drug - Unlikely to Re-Start
Trigger CaseAfterInsertUpdate on Case (after insert, after update) {
    Set<String> caseIds = new Set<String>();
    
    for (Case c : Trigger.new)
    {
        if(Trigger.isInsert)
        {
            caseIds.add(c.Id);
        }
        else
        {
            Case oldCase = Trigger.oldMap.get(c.Id);
            if(oldCase.Nutrition_Consult_Dietitian__c != c.Nutrition_Consult_Dietitian__c)
            {
                caseIds.add(c.Id);
            }
        }
    }
    
    RecordType rt = [select Id from RecordType where Name = 'Nutrition Consult' and sObjectType = 'Case'];
    
    Map<String, String> AccountMap = new Map<String, String>();
    for(Case c : [select Nutrition_Consult_Dietitian__c, AccountId from Case where Id in :caseIds and (Type = 'Initial' or Type = 'Follow Up')  and  RecordTypeId = :rt.Id])
    {
        AccountMap.put(c.AccountId, c.Nutrition_Consult_Dietitian__c);
    }
    List<Account> accounts = new List<Account>();
    for(Account acc : [select Id, RD_Consult__c from Account where Id in :AccountMap.keySet()])
    {
        acc.RD_Consult__c = AccountMap.get(acc.Id);
        accounts.add(acc);
    }
    
    try {
        update accounts;
    } catch (Exception ex) {
        System.debug('Could not update Last Survey Sent field on Account with cause: ' + ex.getCause());
    }
}

Add the logic to this trigger pls
AND ( RecordTypeId = '012E0000000NA5U' , ISBLANK ( Date__c ) , ISPICKVAL ( Status , "Completed" ) )
AND( RecordTypeId = '012L00000000iir',  (Account.Last_Ship_Date__c  > CreatedDate),
ISPICKVAL(Account.AEGR_Pharmacy_Status__c,"Active"),  ISPICKVAL(StageName,"Shipped"))

Can anyone help me on how to add created date in this validation.
I have 2 requirements of trigger

1. SR date field on Case of record type nutrition consult when it is filled it must be updated to account record with SR date field.
2. There must be a validation of before insert when a new case record is created then if the SR date field on account record is filled then they cannot create a new case record type of nutrition consult with type = initial.

Can anyone help in creating a child to parent update of a date field and also a validation like this  by a trigger.
I want to elimiate this Compass copay visiUser-added imageble when they new button for record type selection.
Hi 

 I created formula fields for copying the address fields from contact to child custom oject but the client wants only for the first time when a custom object record is created these address fields on custom object must not get updated every time when a contact mailing address is changed.

How to achieve this?
To disable call logging will also need to be handled in the adapter code. Alternatively, outside of CTI adapter code/toolkit, you could write a trigger on the Task object which intercepts the call log that CTI adapter creates and block it before the insert. The CTI adapter makes a Task of type Call and uses fields such as CallDuration. You could detect if that field value is set and block the Task before an insert.

User-added image
Can anyone help me in changing this query.

for(Veeva_Service_Request__c loopVSR : [SELECT Id, Service_Request_Id__c 
                                                FROM Veeva_Service_Request__c
                                                WHERE Id IN :taskParentMap.values()
                                                    OR Service_Request_Id__c IN :taskParentMap.values()]){