How to check if the doctype is being modified from another doctype?

I am updating the values of doctype A from doctype B. However, in order for a rule in the validation function under doctype A, I need to check if the value changes are coming from another doctype (Doctype B) or from the doctype(doctype A) itself.

That sounds…messy. Under normal circumstances, you wouldn’t want historical information (like the source of a change) to have bearing on document validation. If that information is important, it should be recorded as part of the doctype’s data. You could, for example, add a checkbox field indicating the information implied by the change’s origin.

Perhaps I’m misunderstanding, though. If you explain your use case in a bit more detail, we might be able to give better advice.