Skip to main content

Create a new attribute from default attribute.

  • May 31, 2022
  • 8 replies
  • 366 views

param2022
Jr Varsity II
Forum|alt.badge.img
namespace PX.Objects.CR
{
//
// Summary:
// Attribute to specify system values for PX.Objects.CR.Contact.source, PX.Objects.CR.CRLead.source
// and PX.Objects.CR.CROpportunity.source. Values for those screen should be adjusted
// by adjusting System Workflow for those screens.
public class CRMSourcesAttribute : PXStringListAttribute
{
[Obsolete("This source is used only for backward compatibility.")]
public const string _WEB = "W";
[Obsolete("This source is used only for backward compatibility.")]
public const string _PHONE_INQ = "H";
[Obsolete("This source is used only for backward compatibility.")]
public const string _REFERRAL = "R";
[Obsolete("This source is used only for backward compatibility.")]
public const string _PURCHASED_LIST = "L";
[Obsolete("This source is used only for backward compatibility.")]
public const string _OTHER = "O";
public const string OrganicSearch = "S";
public const string Campaign = "C";
public const string Referral = "R";
public const string Other = "O";
public const string Web = "W";
public const string PhoneInquiry = "H";
public const string PurchasedList = "L";

public CRMSourcesAttribute();
}
}

I want to add some new options in this default attribute. How can I create a new attribute using this attribute ? I have tried extending this attribute in my new attribute but that doesn't work. Can anyone help me here ?

8 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 31, 2022

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • May 31, 2022

@Naveen Boga i tried the code in the link you have shared and it is not working as I want it to. But i think if focuses on creating a new attribute and not extending the existing attribute into newly created attribute.

I am able to create a new Attribute successfully but I don’t want to write the options that are already present in the StringList, I just want to inherit existing ones and add the new ones.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 31, 2022

Hi @param2022  If that is the case, you can refer to the below link.

This article will explain about adding new items to the existing dropdown by inheriting the existing attribute list

https://riptutorial.com/acumatica/example/29102/modifying-marital-statuses

 

hope this helps!


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • May 31, 2022

@Naveen Boga this link has solved a lot of issue. But In one of the dropdown there is this formula that is preventing new fields to be added over there any way to solve this or override this? I created a new field in DACExtension bu still it is not showing updated options over here. At oyher places new options are added sucessfully.

[CRMSources]
[PXDBString(1, IsFixed = true, BqlField = typeof(Standalone.CROpportunity.source))]
[PXFormula(typeof(BqlOperand<Current<source>, IBqlString>.When<BqlOperand<Current<source>, IBqlString>.IsNotNull>.Else<Use<Selector<contactID, Contact.source>>.AsString>))]
[PXMassUpdatableField]
[PXUIField(DisplayName = "Source", Visibility = PXUIVisibility.Visible, Visible = true)]
public virtual string Source { get; set; }

this is the base field I am trying to override.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 31, 2022

Hi @param2022  Did you check by removing the [PXFormula] and [PXMassUpdatableField] attributes?


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • May 31, 2022

@Naveen Boga Yes I have only mentioned this much in my DAC Extension.

[NewSources]
[PXMergeAttributes(Method = MergeMethod.Append)]
      
public string Source { get; set; }
public abstract class source : BqlType<IBqlString, string>.Field<source> { };


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 31, 2022

Hi Param,

Also, try like below.

  • Remove the Base Attribute
  • Then add new attribute i.e. [NewSources]

screenshot for reference.

 

 

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • May 31, 2022

@Naveen Boga 

 

#region
        [NewSources]
        [PXMergeAttributes(Method = MergeMethod.Append)]
        [PXRemoveBaseAttribute(typeof(CRMSourcesAttribute))]
        public string Source { get; set; }
        public abstract class source : BqlType<IBqlString, string>.Field<source> { };
        #endregion

 

this is my current code and after publishing this, it is showing error.