How to access Obsolete variables in graph extension - acumatica

I have field declared with obsolete in some other project, how i can access this field in my extended graph.
[Obsolete("Use AMShiftMst.shiftType", true)]
public abstract class shftDiff : IBqlField, IBqlOperand
{
protected shftDiff();
}

You cannot use this class shftDiff because the ObsoleteAttribute marks any usage as an error. The message in the obsolete call mentions the new object to use.
See ObsoleteAttribute(String, Boolean) here:
ObsoleteAttribute Class
However related to the product it looks like the message should indicate to use AMShiftMst.shftDiff and not AMShiftMst.shiftType as shiftType doesn't exist.
Using AMShiftMSt.shftDiff should solve your issue.

Related

Additional GS1 codes support in Acumatica

We need to add support for GS1 Barcode Customer Part Number in the Purchases - Receive and Put Away screen, it is not supported by default and I can't a find a way to add it.
From looking at the source code, it seems like I need to override GS1Support property or the GetGS1ApplicationSteps() method on PX.Objects.PO.WMS.ReceivePutAway class but I can't find a way to to this. I tried to override using PXGraphExtension method:
public class ReceivePutAway_Extension : PXGraphExtension<ReceivePutAway>
{
}
but then I get the following error:
CS0311 The type 'PX.Objects.PO.WMS.ReceivePutAway' cannot be used as type parameter 'Graph' in the generic type or method 'PXGraphExtension'. There is no implicit reference conversion from 'PX.Objects.PO.WMS.ReceivePutAway' to 'PX.Data.PXGraph' class.
UPDATE:
After updating the extension class declaration as suggested, now the error is gone but I'm still unable to find a way to override GetGS1ApplicationSteps() method on the BLC extension class PX.Objects.PO.WMS.ReceivePutAway, .
Does anybody know how to make the override work for a class like this or maybe has good suggestion on how to add support for additional GS1 barcodes?
ReceivePutAway is not a Graph, therefore you cannot do a simple Graph Extension directly on it. ReceivePutAway inherits from WMSBase which is actually defined as a Graph Extension. This means that you need to end up with a second level graph extension.
If you need to customize ReceivePutAway, I would suggest to try the approach mentioned here:
https://help-2021r1.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=c86fdae8-fef9-4490-aa57-3528d0fa172e
Refer to section 'Second-Level BLC Extension' in the above link. In your case, it might be something like this:
public class ExtensioReceivePutAway_Extension :
PXGraphExtension<ReceivePutAway, ReceivePutAwayHost>
{
}

How to access Custom field,which is defined in Construction feature package- Acumatica

By reading my question, you might think its very easy, but i request everyone to try to access a custom field defined in the construction feature package.
I want to access "Type" field in Project screen's Task Tab in details
UsrType is a custom field defined in Construction features package. In that package, file has been converted into dll. I tried to access that field like we usually do in customization.
but i got error
Type or Namespace "PMTaskExt" could not be found
I even tried this
I got error
UsrType Doesn't exist in PMTask
There is also same problem with UsrSubcontractNbr field in APTran. Not Only these fields, there are many such field to be accessed.
How can we access such fields?
From looking at PX.Objects.CN.dll it would be in the PX.Objects.CN.ProjectAccounting.PM.CacheExtensions namespace as PmTaskExt
Used the latest 19R2 Construction project "ConstructionFeatures_19_205_4_1_157"
Decompiled the customization dll (used DotPeek) I searched for PMTask:
Copied text:
using PX.Data;
using PX.Data.BQL;
using PX.Objects.CN.ProjectAccounting.PM.Descriptor;
using PX.Objects.CS;
using PX.Objects.PM;
namespace PX.Objects.CN.ProjectAccounting.PM.CacheExtensions
{
public sealed class PmTaskExt : PXCacheExtension<PMTask>
{
[PXDBString(30)]
[PXDefault]
[PXUIField(DisplayName = "Type", Required = true)]
[ProjectTaskType.List]
public string UsrType { get; set; }
public static bool IsActive()
{
return PXAccess.FeatureInstalled<FeaturesSet.construction>();
}
public abstract class usrType : BqlType<IBqlString, string>.Field<PmTaskExt.usrType>
{
}
}
}
Something like this should work:
var cnExt = PXCache<PX.Objects.PM.PMTask>.GetExtension<PX.Objects.CN.ProjectAccounting.PM.CacheExtensions.PmTaskExt>((PX.Objects.PM.PMTask)e.Row);
Do note the .Net version of PX.Objects.CN.dll is using 4.8 in case that causes any issues with version compatibility in visual studio if your solution is compiled on the same version of Acumatica for 19R2 which is 4.7.1

Automapper isn't using extension methods for mapping

I have automapper setup like this
services.AddAutoMapper(typeof(MappingAssembly).Assembly, typeof(AssemblyWithExtensionMethods).Assembly);
And in one of my profiles
public class UserModuleMapper : Profile {
public UserModuleMapper() {
IncludeSourceExtensionMethods(typeof(UserGroup));
CreateMap<UserGroup, UserGroupDto>(MemberList.Destination);
}
}
And I have defined the extension method as
public static List<string> GetRoleNames(this UserGroup group) {
return group.UserGroupRoles.Select(x => x.Role.Name).ToList();
}
I have a property on DTO defined as
public List<string> RoleNames { get; set; }
As per the automapper documentation, I have made the following assumptions:
IncludeSourceExtensionMethods, which include extension methods while mapping
while mapping it will also look for methods with prefix Get
But when I validate the automapper extension I get error for unmapped property
Unmapped properties: RoleNames
What is missing in my configuration, automapper should detect the extension method.
I have tried (a) remove GET from the method name, but still does not work (b) moving CreateMap before or after the IncludeSourceExtensionMethods to see if sequence matters, but none of it helped.
With in few minutes after posting the question I got the answer by carefully looking at this issue on Github
The issue was with below statement
IncludeSourceExtensionMethods(typeof(UserGroup));
the type mentioned here should be of extension class
IncludeSourceExtensionMethods(typeof(UserGroupExtensions));
Not deleting the question, as it might help someone in future.

How do I correct PX1011 warning from Acuminator? (it suggests sealing class, but that causes errors in error list)

I needed to add a new field to SOOrder and update attributes of another field. Both classes inherit PXCacheExtension, and both give a PX1011 warning that
Because multiple levels of inheritance are not supported for PXCacheExtension, the derived type can be marked as sealed. I had extended it originally from within Acumatica 2018R1 but have moved the code from within the customization project into my Visual Studio Extension Library.
I started with:
public class SOOrderExt : PXCacheExtension<PX.Objects.SO.SOOrder>
If I change the declaration of the class to be:
public sealed class SOOrderExt : PXCacheExtension<PX.Objects.SO.SOOrder>
I get CS0549 SOOrderExt.UsrMyField is a new virtual member in a sealed class 'SOOrderExt'.
Thinking that maybe I missed something and don't need to declare my virtual int?, I commented out:
public virtual int? UsrMyField { get; set; }
and got CS1061 'SOOrderExt' does not contain a definitionfor 'UsrMyField' and no accessible extension method 'UsrMyField; accepting a first argument of type 'SOOrderExt' could be found.
Is the original PX1011 warning something I should ignore, or is there something special needed to follow the guidance to make it sealed or to know that sealing the class is not appropriate?
In short, how do I make these Acuminator warnings go away without simply suppressing and still define my fields?
I'm on 2018R2 Build 18.212.0033 with Visual Studio 2019 Community Edition and Acuminator 1.6.1.
You need to declare the property but the virtual keyword doesn't seem necessary. Otherwise the warning is an oversight if sealed = no virtual and no virtual = no custom fields.
Without virtual keyword this cache extension seems to be working fine:
public sealed class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region UsrField
[PXDBString(12)]
[PXUIField(DisplayName="Field")]
// Ommit declaring the type as virtual
public /*virtual*/ string UsrField { get; set; }
public abstract class usrField : PX.Data.BQL.BqlString.Field<usrField> { }
#endregion
}

ServiceStack - generate ASP.NET webservice -reference issue

I am using the very excellent servicestack libaries and trying to generate a ASP.NET web-service reference (old style not WCF) from within VS2010 across my servicestack WSDL - Soap11. To nicely wrap the service WSDL.
The DTO's are in a seperate assembly/namespace (My.WS.DTO) from the AppHost/services and are following the request/response naming convention.. when I try to generate the reference through visual studio I get the following error in VS.
Custom tool error: Unable to import WebService/Schema. Unable to import binding 'BasicHttpBinding_ISyncReply' from namespace 'http://schemas.servicestack.net/types'. Unable to import operation 'GetMyDetails'. The element 'http://schemas.servicestack.net/types:GetMyDetails' is missing.
NOTE: GetMyDetails is just the first service that appears in the list - so I dont believe this is the problem.
I have tried adding the assembly namespace in the AppHost file using
EndpointHostConfig.Instance.WsdlServiceNamespace = "My.WS.DTO"; and this just causes the same generation error (as above) but with 'My.WS.DTO' instead of 'http://schemas.servicestack.net/types'.
I assume it is perhaps some sort of referencing problem but any guidance as to what I might be doing wrong would be great.
cheers
I don't know if this is still an issue for you but I had a similar problem and found that I had not decorated one of my DTOs with [DataContract] and [DataMember] attributes, as described on the SOAP Support wiki page. Once you have added these to your DTO it will be declared in the type section of the WSDL.
Have a look at using [DataContract (Namespace = "YOUR NAMESPACE")] on top of your DTO's. This is how my objects are referenced.
[DataContract(Namespace = "My.WS.DTO")]
public class Account{
}
I also use this in my service model. [System.ServiceModel.ServiceContract()] and [System.ServiceModel.OperationContract()]
[System.ServiceModel.ServiceContract()]
public class SendGetAccountResponseService : IService<SendGetAccountNotification>
{
#region IService implementation
[System.ServiceModel.OperationContract()]
public object Execute (SendGetAccountNotification request)
{
Console.WriteLine ("Reached");
return null;
}
#endregion
}
Hope this helps / solves your problem.
I know this is an old question, but I had to add SOAP support for a 3rd party that refused to support REST very recently to my ServiceStack implementation so it could still be relevant to other people still having this issue.
I had the same issue you were having:
Unable to import binding 'BasicHttpBinding_ISyncReply'...
And like mickfold previously answered I needed to add [DataContract] and [DataMember] to my class definitions and their properties.
But I also had to add the following to my AssemblyInfo.cs file before the error went away for me:
[assembly: ContractNamespace("http://schemas.servicestack.net/types", ClrNamespace = "My Type Namespace")]
I assume that you will need one of these lines for every single namespace where you have a type declared, which based upon the original question above would be My.WS.DTO.

Resources