销售价格每隔一次更新

时间:2018-07-27 19:14:28

标签: acumatica

我扩展了SOOrderEntry图并添加了以下代码,以便更新与当前要更新的当前行相关的同一销售订单上的另一行:

protected virtual void SOLine_RowUpdating(PXCache cache, PXRowUpdatingEventArgs e)
{
    if (e.NewRow == null)
    {
        return;
    }

    SOLine soLine = (SOLine)e.NewRow;

    SOLine relatedLine = Base.Transactions.Search<SOLine.inventoryID> 
    (456);

    if (relatedLine != null)
    {
           relatedLine.Qty = soLine.Qty;
           relatedLine.CuryUnitPrice = 24.20;

           Base.Transactions.Update(relatedLine);
           Base.Transactions.View.RequestRefresh();
    }
}

当我尝试通过更新当前行上的数量进行测试时,相关行上的单价只会在我更新数量时每隔一次更新一次。相关物料是非库存物料,其中当前物料是库存物料。

我正在18.102.0048的Sales Demo环境中进行此操作

我尝试过此操作,但现在扩展价格始终为0.00:

protected virtual void SOLine_RowUpdating(PXCache cache, PXRowUpdatingEventArgs e)
{
    if (e.NewRow == null)
    {
        return;
    }

    SOLine soLine = (SOLine)e.NewRow;

    SOLine relatedLine = Base.Transactions.Search<SOLine.inventoryID> 
(456);

    if (relatedLine != null)
    {
       SOLine oldRelatedLine = PXCache<SOLine>.CreateCopy(relatedLine);
       relatedLine.Qty = soLine.Qty;
       relatedLine.CuryUnitPrice = 24.20;

       Base.Transactions.Cache.RaiseRowUpdated(relatedLine, oldRelatedLine);

       Base.Transactions.Update(relatedLine);
       Base.Transactions.View.RequestRefresh();
    }
}

2 个答案:

答案 0 :(得分:0)

当一个字段的计算值取决于另一个字段的值时,有时需要触发事件以重新计算该值。

在某些情况下,仅需要为您修改的字段触发事件。使用C#赋值运算符(=)或SetValue方法分配值不会触发事件处理程序,SetValueExt方法将:

// Doesn't trigger events
relatedLine.Qty = soLine.Qty;
cache.SetValue<SOLine.qty>(relatedLine, soLine.Qty);

// This will trigger events
cache.SetValueExt<SOLine.qty>(relatedLine, soLine.Qty);

在某些情况下,您也需要为整个行触发事件。您可以使用RaiseXxxYyy方法执行此操作。我在示例中使用了Current,但如果Current不是要修改的行,则可能必须对其进行修改:

SOLine oldRowCopy = PXCache<SOLine>.CreateCopy(Base.Transactions.Current);
Base.Transactions.Current.Qty = soLine.Qty;
Base.Transactions.Cache.RaiseRowUpdated(Base.Transactions.Current, oldRowCopy);

编辑

看着更新的问题,可能不会有太大的区别,但我建议您切换这两行的顺序:

   Base.Transactions.Cache.RaiseRowUpdated(relatedLine, oldRelatedLine);
   Base.Transactions.Update(relatedLine);

赞:

// You want the value in Cache to be updated
Base.Transactions.Update(relatedLine);

// After Cache value is set you want to raise the events
Base.Transactions.Cache.RaiseRowUpdated(relatedLine, oldRelatedLine);

答案 1 :(得分:0)

感谢HB_ACUMATICA,下面是解决此问题的代码:

ssh -v hdpuser@35.200.208.150

OpenSSH_7.6p1 Ubuntu-4, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 35.200.208.150 [35.200.208.150] port 22.
debug1: Connection established.
debug1: identity file /home/hdpuser/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hdpuser/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4
debug1: match: OpenSSH_7.6p1 Ubuntu-4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 35.200.208.150:22 as 'hdpuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ATVf5KnwDP1DX0+m/LnByw6aMQg8wsdFW9i2OPooDEE
debug1: Host '35.200.208.150' is known and matches the ECDSA host key.
debug1: Found key in /home/hdpuser/.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:VOpdHWpG5bRrArm6CWp86qKoPU33TmipL3l6KLXMrzo /home/hdpuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/hdpuser/.ssh/id_dsa
debug1: Trying private key: /home/hdpuser/.ssh/id_ecdsa
debug1: Trying private key: /home/hdpuser/.ssh/id_ed25519
debug1: No more authentication methods to try.
hdpuser@35.200.208.150: Permission denied (publickey).